Parsing JSON from a text file in Keyboard Maestro

I’m having trouble parsing a document that has JSON in it. Ideally, I’d like to read from a variable file (extracted from a loop over the directory) and read the JSON into some variable/dictionary that I can later get the data out of. I’ve tried using the Set Dictionary to JSON action, but it seems to be having trouble with parsing the variable.

Any help would be appreciated.

Can you share the JSON?

1 Like

You might have more luck posting this on the Keyboard Maestro forum at https://forum.keyboardmaestro.com.

Lots of active users, and the developer is there too.

I figured out what I needed. Thanks.

Can you please provide the details of what you have done?

The chances are high that someone else looking for help on a similar challenge could find this topic, so it is always useful to explain causes of issues, actions to resolve, workarounds applied, etc. so others can benefit from it.

1 Like

I didn’t actually need a dictionary - I just needed a way to get values out of the JSON. And KM provides a token for this: %JSONValue%VariableName.field{field}[1]%. The variable itself I could populate from a Read from a File action, which itself can take a variable. Part of the problem I was having was that when I was clicking the ‘try’ it was only trying the single action I had selected, so the data wasn’t being carried over. I later realized that I had to select the entire For loop and then hit try.

I’m still working on the Web integration bit. I’m not quite sure how to talk to a series of webpages with variable input effectively. I’ll have to play with it a bit.

2 Likes