Sorry, I meant to explain that the JSON response is just a static value for the JSON you posted above. Instead of calling the server, I just used your response. It has the same effect so it’s useful for testing the blocks, especially for APIs where I wouldn’t have a key to access them.
But you’re right, the JSON is going to be dynamic (different every time). If the format of the JSON is the same but the values changes, then you’re fine using the blocks I provided. You just wouldn’t need the static JSON text. You’d replace that with the actual JSON response (green [response] block).
If the format changes, then you are in for quite a ride… and I’d need to see some examples of what that looks like in order to advise you.
The main problem with your blocks is that you are assuming that the “vehicle_reg” property you’re getting from your API is an array/list. It isn’t. Square brackets in JSON [ ] represent an array. Curvy brackets { } represent objects.
A list of objects would look like this:
"vehicle_reg": [
"123456": {
"model": "234566",
"colour": "098765",
"cognito_id": "5820d31f-8d80-41c2-8372-f5aade306d20",
"lpn": "123456",
"make": "123456"
},
"123ABC": {
"model": "Vroom vroom",
"colour": "Pink",
"cognito_id": "5820d31f-8d80-41c2-8372-f5aade306d20",
"lpn": "123ABC",
"make": "Toyota"
}
]
But what you’re seeing is an object with objects inside:
"vehicle_reg": {
"123456": {
"model": "234566",
"colour": "098765",
"cognito_id": "5820d31f-8d80-41c2-8372-f5aade306d20",
"lpn": "123456",
"make": "123456"
},
"123ABC": {
"model": "Vroom vroom",
"colour": "Pink",
"cognito_id": "5820d31f-8d80-41c2-8372-f5aade306d20",
"lpn": "123ABC",
"make": "Toyota"
}
}
So you’re stuck using “get property of object” blocks. What I did to make the blocks access multiple nested properties/objects is to use the “get object properties of” block. That’s a special block that is used to get the property names from inside of an object. I assign that to the loop variable j and then use j in place of the actual property name such as “123ABC” or “AAAA”.
I’m sure that’s still a little confusing but I’m not sure how else to explain it!