[Solved] How do I set API Headers?

There are two problems with how you are trying to parse the JSON response:

  1. When you get a property of an object, it will return a text string (so “food_name” will return “Rice Krispies”, for example). You should not then convert that text string back to JSON. That will just add unnecessary symbols such as { } to your result. So remove the generate JSON from object block.

  2. The square brackets [ ] in a JSON response indicate an array (list):

{
“foods”:[
{

So you’ll need to use List blocks to access that data or use property notation that includes list indexing. You also need to include the top property in the JSON path. So for example, to get “Rice Krispies” as a result, you’d need to get the property “foods[1].food_name” where “foods” is the top property name and [1] is the list index for the first item in the “foods” array.

If your “foods” list contains more than one item, then you’d need to reference additional items using their index value (such as “foods[2].food_name”) or use a loop to loop through them with the loop counter ‘j’ in place of the integer [2].

In case you’re interested, I have a video that explains JSON parsing here: API JSON Tutorial (Video)

1 Like