238
Views
4
Comments
Solved
Add Structure from JSON Error
Question

hi there,

I am wondering why:

1. i check a json structure online.. it is valid

2. then i create structure from JSON in outsystems, it is error:


3. the error is caused by there are keys with same names (see Max), like (i truncate my json as it is

too long..):

"xx": {      
                "aa": {        
                    "Max": 5,
                            "Current": 5      
                },
                      "bb": {        
                    "Max": 5,
                            "Current": 5      
                },
                      "cc": {        
                    "Max": 5,
                            "Current": 5      
                },
                      "dd": {        
                    "Max": 5,
                            "Current": 5      
                },
                      "ee": {        
                    "Max": 5,
                            "Current": 5      
                },
                      "ff": {        
                    "Max": 5,
                            "Current": 5      
                }
            }

I workaround by renaming the last Max to say it MaxTwo, and all will be okay.

regards,

Gede

2018-01-19 03-18-31
indra budiantho
Solution

hi, David,

Thank you for quick reply.

Actually, i have simplified the sample. In my complete one, before  the  only one "alert", there are also other keys that need to distinguish. like: "mime_type2",      "width2": ..."title2", "height2, etc.

I do increment debug, so before add the "alert" json key-value codes, there are the same errors for  "mime_type2",      "width2": ..."title2", "height2, etc.

Hopefully that Outsystems JSON expert will fix it later, so if it is valid then Outsystems will do.

see also: https://www.outsystems.com/forums/discussion/34643/how-to-deserialize-this-json/

regards,

GEde

2020-03-05 14-29-02
José Costa

Hi Gede,

I've tried your JSON to create a structure and I did not have any issue. Do you have an issue with that JSON or only when the JSON is too long?

Also, I'm using Service Studio 10.0.807.0. Which version are you using?

Cheers,

José

2018-01-19 03-18-31
indra budiantho

Hi, Jose,

I have attached the complete json that is valid according to https://jsonlint.com/?code=

and if i change the last key name "Max" to "Max2", the json structure is generated, otherwise error as mentioned above:

 "Problem": {      
"call": {        
"Max": 5,
        "Current": 5      
},
      "notification": {        
"Max": 5,
        "Current": 5      
},
      "music": {        
"Max": 5,
        "Current": 5      
},
      "system": {        
"Max": 5,
        "Current": 5      
},
      "alert": {        
"Max": 5,
        "Current": 5      
},
      "ring": {        
"Max": 5, ---- change to "Max2"
        "Current": 5      


I use:

Thank you,

regards,

Gede

Problem.txt
UserImage.jpg
Davidk

I'm not sure why changing Max to Max2 works... that's bizarre... works for me too.

However, I feel the problem is in using a reserved word... in this case "alert".

If I use your JSON, I get the same error you're getting.  If I use this JSON... all is ok.  I've changed "alert" to "myAlert".

{
"Problem": {
"call": {
"Max": 5,
"Current": 5
},
"notification": {
"Max": 5,
"Current": 5
},
"music": {
"Max": 5,
"Current": 5
},
"system": {
"Max": 5,
"Current": 5
},
"myAlert": {
"Max": 5,
"Current": 5
},
"ring": {
"Max": 5,
"Current": 5
}
}
}

2018-01-19 03-18-31
indra budiantho
Solution

hi, David,

Thank you for quick reply.

Actually, i have simplified the sample. In my complete one, before  the  only one "alert", there are also other keys that need to distinguish. like: "mime_type2",      "width2": ..."title2", "height2, etc.

I do increment debug, so before add the "alert" json key-value codes, there are the same errors for  "mime_type2",      "width2": ..."title2", "height2, etc.

Hopefully that Outsystems JSON expert will fix it later, so if it is valid then Outsystems will do.

see also: https://www.outsystems.com/forums/discussion/34643/how-to-deserialize-this-json/

regards,

GEde

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