For implementing a build monitor I perform an API request to a Jenkins server (URL call) that returns JSON. From this JSON only some values (for certain keys, like "result" and "number") are relevant.
My first attempt was to put the (JSON/text) result of the URL call in a dictionary and then get the relevant info. This works in isolation, but I want to have multiple monitors (for multiple repos/branches). Apparently that dictionary is shared by all instances of my subroutine, causing the wrong build status to be displayed.
How can I get specific JSON values without using dictionaries?
(Or better: in such a way that I can run multiple instances of my subroutine in parallel without interference?)
Have you looked at the features that KM provides to use JSON? A good place to look is here: action:Set JSON Value [Keyboard Maestro Wiki] which also has links to the other JASON features.
I have (briefly) tried the JSONValue token before posting, but failed.
Is putting the (JSON) text our Jenkins server returns in a variable sufficient to have JSON in a variable, or do I need to do something special to let KM know it’s JSON and not (any) plain text?
Additional question: suppose the JSON is stored in variable localJSON and I want to fetch data for several keys (currently, "result" and "number"), do I need to hardcode them all like this?
%JSONValue%localJSON.result%
%JSONValue%localJSON.number%
Or can I do this (and make localParameter and input parameter of my subroutine)?
* %JSONValue%localJSON.%Variable%localParameter%%
(an in-between solution is to use a switch, but then I still need to hardcode all keys I want to support)
I agree with rob that something seems wrong when neither the JSONVALUE function nor the CALCULATE function seem to work as the wiki says they should. Tiffle is using the JSONValue token instead of these functions, which works. That's a workaround, but it's still an open question why neither of the functions work. A workaround is always good, but a workaround doesn't answer the question.