Hi
I have a dynamic list behaviour container, which gets filled when I hit a button to call a JS API that returns a JSON object. I get a successful response, I can get the keys from the JSON if I Alert them.
But, I can’t seem to get the rows of that JSON into a cell in the container. Seems to be no way to reference the JSON object key/value pairs ? I’m sure I’m missing something simple.
App Id : A603AF06-3DDD-6D47-FF01-D559C4DF9300
Can you please help ?
Thanks
Paul
Hi @paul-barnes
Do you want to get the list of key-value pairs of your json object and set it to your dynamic list?
Best Regards,
Maksym
Hi
Yes. Well actually, I want to be able to split out into separate lists each of the arrays in the JSON.
For example, there might be a collection of people, inside there’s an array of people key/value pairs.
This will be assigned to list one. Then there’s a collection of cars, inside there’s an array of car key/value pairs. This will be assigned to list two. And so on.
Here is a rough example how to retrieve data from json (and create lists based on it):
Main points:
- api service returns JSON object that is assigned to var
data
- then we iterate the keyset of json object and create the object for each key, that contains two fields:
key
and value
. The result (list of objects) is assigned to var items
- Last step - assign list to our dynamic list. Don’t forget to set Content Logic for text components.
Best Regards,
Maksym
2 Likes
Thanks Maksym. That seems to have worked, using the Map Items function. Is there any documentation on how the Map Items function works ? Does it work for JSON objects and arrays ? To get deeper nested objects in the JSON object, presumably you need to get the initial Map Items list, then traverse the contents of that ?
Many thanks.
1 Like