Getting the Results of a JSON/XML Query

I'm glad Peter is on this case now. But I will point out that the script I send you works for me. That is, it returns results. It returns this:

{"metaData":{"apiVersion":"0.2","warning":"ACHTUNG: Bitte vor ernsthafter Nutzung feedback@openthesaurus.de kontaktieren, um bei API-\u00c4nderungen informiert zu werden","copyright":"Copyright (C) 2019 Daniel Naber (www.danielnaber.de)","license":"Creative Commons Attribution-ShareAlike 4.0 or GNU LESSER GENERAL PUBLIC LICENSE Version 2.1","source":"https://www.openthesaurus.de","date":"Wed Jul 03 20:38:07 CEST 2019"},"synsets":[]}

I can't see why running the same script wouldn't work for you.

@Sleepy: Yours did work!! But what is the difference in grouping all those steps?

The only reason I grouped them is because then I could run them more easily using a cogwheel. I didn't want to set a function key.

If mine worked, what changes did you make to make it fail?

From my point of view there is no difference other than the group...

Did you copy my macro's actions into your program or did you just visually look for differences?

I copied it. What's still odd is the fact that, while results are shown in the output, there are new synonyms in it. But I will work that out.

Thank you all very, very much for your great help!!

Then I'll let you think about it. I'm glad my macro worked. Please come back if you have any further questions. Don't be afraid, I want to help.

I've found one little error (the '$' in front of KMVAR_varSyn was missing).
Now it's:

myQuery="https://www.openthesaurus.de/synonyme/search?q=$KMVAR_varSyn&format=application/json"
curl -sL --url $myQuery

Dang, did I make a mistake? SORRY!

The Macro is pretty useful right now. However I'm thinking about a more sophisticated version.

The results I get after the macro has run look like this:

{"metaData":{"apiVersion":"0.2","warning":"ACHTUNG: Bitte vor ernsthafter Nutzung feedback@openthesaurus.de kontaktieren, um bei API-\u00c4nderungen informiert zu werden","copyright":"Copyright (C) 2019 Daniel Naber (www.danielnaber.de)","license":"Creative Commons Attribution-ShareAlike 4.0 or GNU LESSER GENERAL PUBLIC LICENSE Version 2.1","source":"https://www.openthesaurus.de","date":"Sun Oct 13 20:51:31 CEST 2019"},"synsets":[{"id":34416,"categories":[],"terms":[{"term":"damals"},{"term":"in jenen l\u00e4ngst vergangenen Tagen"},{"term":"in jenen (fernen) Tagen"},{"term":"in jener l\u00e4ngst vergangenen Zeit"},{"term":"seinerzeit"},{"term":"zu dieser Zeit"},{"term":"zu jener Zeit"},{"term":"zum damaligen Zeitpunkt"},{"term":"da","level":"umgangssprachlich"}]}]}

I'm thinking about getting the JSON values for "term" and put them in a prompt. So the workflow would be to select a word, then fire up the macro and, in this case, get synonyms for the word. The results will be selectable in a prompt, I chose the one that suits me and the aforementioned selected word will be replaced by the synonym.

Would that be doable with KM?

Thanks a lot in advance!

1 Like

Something like this:

Keyboard Maestro Actions.kmactions (3.0 KB)

2 Likes