589
Views
4
Comments
Solved
How to convert javascript text output to list
Question
Application Type
Mobile

Hi all,

How to convert the javascript text output to the list in Outsystems?

Javascript function output: "[{"item":{"Value":"karan"},"refIndex":0},{"item":{"Value":"khij"},"refIndex":1},{"item":{"Value":"kaustubh"},"refIndex":2},{"item":{"Value":"karan"},"refIndex":5},{"item":{"Value":"khij"},"refIndex":6},{"item":{"Value":"kaustubh"},"refIndex":7}]"

I want to convert this into list so that I can access the "Value" parameter in the screen. I used the JSON deserialize but not sure what datatype needs to be set in JSON deserialize action.

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Kaustubh,

For the mentioned use-case, follow the below steps:

Implementation Steps

1) Create a structure based on the shared JSON string, using the Add Structure from JSON option

2) When you deserialize the JSON string, make sure that you set the Data type as Structure List Type as shown below 

3) After Deserializing the JSON string, assign the Ouptut to the Structure List type Local variable

See this sample screen JSON

Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam

PWAJSON.oml
2021-04-17 09-53-48
José Gonçalves

Hi Kaustubh,

which values from the output you want to put in a list?

karan, khij, kaustubh, karan, khij, kaustubh ?

Regards

2023-06-10 09-22-21
Kaustubh Kamble

Yes jose, only the values karan, khij, kaustubh, karan, khij, kaustubh 

2025-10-09 15-40-22
Craig St Jean
Staff


Hello Kaustubh,

You have a couple of options. If you want to return the list as is, you can create a structure like this:

(make sure to set the JSON... property on the items). You can then use JSONDeserialize

-Or- if you want to return a list of just the values, you can use JavaScript like:

GetList().map(function(x) { return x.item.Value; });


2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Kaustubh,

For the mentioned use-case, follow the below steps:

Implementation Steps

1) Create a structure based on the shared JSON string, using the Add Structure from JSON option

2) When you deserialize the JSON string, make sure that you set the Data type as Structure List Type as shown below 

3) After Deserializing the JSON string, assign the Ouptut to the Structure List type Local variable

See this sample screen JSON

Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam

PWAJSON.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.