1561
Views
4
Comments
JSON Serializing
Question

 

I'm trying to Convert a structure to a JSON string, so I'vedefined a local variable (Var1) as a structure that I defined (see attachedbelow) then in my action I've assigned and hardcoded (just for testing) a valuein one of the fields of the local variable structure(Var1.Update.Description.Current.Set="updated") )then in my JSONSerializer data to the local variable Var1, then assign the JSON result toanother local variable Var2 (JSONSerialize1.JSON)) so I can show it in a textbox but all I get is empty JSON like this:{"update":{"description":[]}}, no Set value.

so what am I doing wrong?






Thanks



UserImage.jpg
Ky

Hi John ,

You need to add JSON Deserialize after your JSON serialize.

JSON string set to JSONSerialize.JSON and data set to your variable.

Please set your variable as record list.

After JSONDeserialize, you should assign your fields in var 1 to the variable record list accordingly.


Best Regards,

Wen Kai




UserImage.jpg
john smith

Hi Wen,

I'm not looking to deserialize JSON, I'm actually looking to get the JSON string as is because I need to use as is somewhere, so I want to have a JSON string in a variable ?


Thanks




UserImage.jpg
Ky

Hi John,


You can take a look at this post which helps to explain.

https://www.outsystems.com/forums/discussion/42131/deserialise-to-list/



You need to add this structure to get the position and value of the string.


add var 1 and var 2 as local variable and type set as text



Set Var 1 as this. Please change accordingly to how many values you need to store in your string.


Set data type to structure record list.







I just tested. You can pass to another variable set as text.

Hope this might help you.


Best Regards,

Wen Kai

jsondatatype.JPG
2020-03-05 09-05-43
Vaibhav Shukla

Hi john,


i would recommend creating a local variable of the structure type and then using list append function to add the value to your var1.


The reason being your list of var1 is empty if you try to initialize with a current value as you're using a nested structure.


Regards,

Vaibhav

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