Ahh! Can't figure out JSON parsing

First-time poster - be gentle. I can't believe it's taken me so long to discover Keyboard Maestro. I've already managed to do so many useful things but one that I just can't seem to get my head around is parsing a somewhat complicated JSON. I have an Airable databased that gets populated with Random Thoughts and actions during the day and I want to parse some key fields from yesterday into markdown format for review the next day.

Airtable presents the response as a JSON:


{"records":[
{"id":"text",
"fields":{
    "Date":"date",
    "Item":"text",
    "Created":"timestamp",
    "Modified":"timestamp",
    "formula":0},
"createdtime":"timestamp"},
{"id":"text",
"fields":{
    "Date":"date",
    "Item":"text",
    "Created":"timestampstamp",
    "Modified":"timestamp",
    "formula":0},
"createdtime":"timestamp"}
]
}

I need to iterate through each of the records and extract the text from the field Item to a temporary variable so I can do all the other stuff I need to do. I've tried for several hours to get the right combination of JSONValue but am lost and even considering resorting to javascript which is crazy because I know this must be possible. Any help gratefully received.

This forum has a number of JSON parsing examples that should help you figure this out. I recommend starting with this one by KM's developer, @peternlewis: Multi-level JSON

If you still can't seem to get it right, feel free to post again, but please provide some examples of exactly what fields you want to parse and what you want to do with them afterwards. Tip: How Do I Get The Best Answer in the Shortest Time?

1 Like

Thanks - I thought I had been following that but it was clearly late last night. I have tried again in the fresh light of day (although it's now almost 90 degrees here) and have the solution below. I was just getting my indexes [ ] and keys { } confused.

2 Likes