getting an error when I am trying to assign an object to a variable
Question
Application Type
Mobile

I am assigning a js object to a local variable on onInitilize but its throwing error saying invalid syntax. Not sure what I am doing wrong. Type matches with the object schema

mvp_badge
MVP
Solution

Hi Lekhaj,

As per the shared screen captures, I think you are using the JSONDeserialize node in some action flow to deserialize the JSON string.

If you are setting a hardcoded (string) value in the expression editor, the string value must be enclosed with double quotes (""). If you are using/defining additional double quotes within the outer double quotes, you need to escape them by doubling them, i.e. you will have to include an additional double quote to escape.

So, the final hardcoded object (string) value will look something like this..

"{
    ""issuedDeviceReference"": ""jit_funding_card_product"",
    ""positionId"": ""4b7Mc6PM0n8Tu----FLF-Co-"",
    ""cardIssuerPartyReference"": ""4v7MX434-Czf_k---VDF-Bg-"",
    ""acctType"": 20,
    ""acctPriority: 1"",
    ""role"": ""personal""
}"


Hope this helps you!


Kind regards,

Benjith Sam

Champion

Hi Lekhaj Grandhi

Afaik, you cant set a json to object directly.

Please use JSON_Deserialize.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Traditional_Web/Web_Logic_Tools/JSON_Deserialize

Kind regards,




Hi tom, 

I am getting syntax error during deserialization aswell

Hi Lekhaj Grandhi

Please check below video ->

How to handle json data ?   

you can not directly assign JSON string to variable value 

Thank you

Hi Rahul, 

There seems to be no issue while handling the data coming from database , but when I want to assign a hardcoded json to a local variable its throwing syntax error during deserialization aswell .

mvp_badge
MVP
Solution

Hi Lekhaj,

As per the shared screen captures, I think you are using the JSONDeserialize node in some action flow to deserialize the JSON string.

If you are setting a hardcoded (string) value in the expression editor, the string value must be enclosed with double quotes (""). If you are using/defining additional double quotes within the outer double quotes, you need to escape them by doubling them, i.e. you will have to include an additional double quote to escape.

So, the final hardcoded object (string) value will look something like this..

"{
    ""issuedDeviceReference"": ""jit_funding_card_product"",
    ""positionId"": ""4b7Mc6PM0n8Tu----FLF-Co-"",
    ""cardIssuerPartyReference"": ""4v7MX434-Czf_k---VDF-Bg-"",
    ""acctType"": 20,
    ""acctPriority: 1"",
    ""role"": ""personal""
}"


Hope this helps you!


Kind regards,

Benjith Sam

mvp_badge
MVP

You're welcome, Lekhaj.

Glad to help you :)


Kind regards,

Benjith Sam

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