How to get a value out of a JSON Array

I’m using the action"Get contents of" which returns a JSON array like this:

   {id: 123, name: "Darth Vader"},
   {id: 456, name: "Luke Skywalker"}

I want to get the value of id by filtering by the name. For example I want to get the id for “Luke Skywalker” Any ideas?

With the data structured as above, you would need to iterate through each array element (it isn’t a dictionary so no key value pair to utilise) and get the resulting dictionary. Then if the name value in that dictionary matches your search term, you return the value of the id entry in the dictionary.

If your actual data set is large, I would also consider adding an additional flag to say whether to bother reading in any additional array elements after a match is made.

Hope that helps.

Thanks I have it working. Seems a little bit more complicated than it needs to be though.

If you happen to have control over the data structure, then you could make it more efficient, but otherwise, it is just standard approach for each of the two data structures - iterate over the array elements and reference the object properties.