[ANSWERED] Json question (id)
-
Hello all,
I am studying Json structure to better understand the bundling and the parsing of data. Although Mark's examples in the help section of the site are clear and function perfectly I tried other examples and I wasn't able to make the work completely. I think it has to do with how Isadora is managing the id
{
"student": [
{
"id":"01",
"name": "Tom",
"lastname": "Price"
},
{
"id":"02",
"name": "Nick",
"lastname": "Thameson"
}
]
}As you can see in the image it is pretty simple, but Id don't seem to work correctly. The example was taken here
What is wrong ?
Thanks -
@armando said:
pretty simple, but Id don't seem to work correctly
I believe it is working as expected. The issue here is that the selection is not done using the "id" value in the JSON data. The selection is made based on the numeric index. The index is zero-based, so this is why you see selecting 0 outputs the JSON with the 'id' of '01'. The position-based index has no relationship to the data's "id".
If you want to combine the selections together so you use fewer JSON Parsers, I added a few to the bottom of this screen capture.
If you want to get the data for a Student where the "id" value equals a specific value you need to send the JSON into the Javascript actor and loop through the values looking for a match.
-
Thanks a lot @dusx,
everything works like a charm now, Although I don't really get the javascript workaround to use less Json parsers and "loop through the values. Whwt do you mean can you give an example please ?
Thanks
Armando
-
@armando said:
loop through the values
I wasn't sure how you wanted to find the values.
For example if you wanted the values for any student with the lastname "Price", using javascript you could search all the students and return the records for any that match.
In the case of these student ID's you might search for the student with the id of "01" get the details for Tom Price. -
@dusxThanks,
I still don't know wow to do that in Javascript, bit it is nice to know that is is possible.
Thanks again