Parsing json ignores elements with $ naming
Question
Application Type
Service
Platform Version
11.14.0 (Build 34092)

I have an Exposed POST method endpoint that consumes a Json body as (simplified) below.

{

    "transactions": [{

        "$type": "value0",

        "$values": [{

            "$type": "value1",

            "id": "value2"

        }]

    }]

}


When receiving calls to this endpoint, the names preceded by $ seem to be ignored by Outsystems. This can be tested by echoing back the request. The reponse is:

{    "transactions": [        {}   ]}


The catch is that the naming of the attributes and objects are given. A workaround by renaming these isn't feasible. 

Any thoughts how to tackle this issue?

Hi Marcel,

if we are working under the assumption that Outsystems can't deal very well with the $ signs in the names, a possible avenue to explore is manipulating the returned json in the OnResponse, making it more digestable by Outsystems.

So remove all $ from the names in the JSON (carefull not remove any $ from the content, though), and also take out al the $ signs in the Name In JSON properties.

Worth a try

Dorine

hi Dorine,

Your approach is working. Thanks a lot for that. Since it's not a preferred handling and error prone, I'm also submitting it for Outsystems support to have a look at.

Cheers,

Marcel 

Hi  Marcel,

Try to set the special character in "Name In JSON" property of the structure attribute, like show in the below image.


Usually if you create a structure using "Add Structure From JSON" feature in outsystems service studio, mostly you won't face these kind of issues.

I hope my solution will help you.

Regards,

Koushik



Hi Koushik,

Thanks for your inputs. The structure was created through "Add Structure From JSON" and contains $type and $values as "Name in JSON". So unfortunately isn't resolving the issue.  


Update:

If I alternate the namings and remove the $, te results are seemingly unpredicatable. If for instance I remove the $ on the first "type", then the request results into an incomplete response:

Request:

{  "transactions": [    {      "type": "type1",      "$values": [        {          "$type": "type2",          "id": "id2"        }      ]    }  ]}

Response: 

{    "transactions": [        {            "type": "type1",            "$values": [                {                    "id": "id2"                }            ]        }    ]}

If I do have the original names with $, then in the Test module the reponse is a failed to parse.....

{    "Errors": [        "Failed to parse JSON request content."    ],    "StatusCode": 400}

Test.oml

Hi Marcel,

if we are working under the assumption that Outsystems can't deal very well with the $ signs in the names, a possible avenue to explore is manipulating the returned json in the OnResponse, making it more digestable by Outsystems.

So remove all $ from the names in the JSON (carefull not remove any $ from the content, though), and also take out al the $ signs in the Name In JSON properties.

Worth a try

Dorine

hi Dorine,

Your approach is working. Thanks a lot for that. Since it's not a preferred handling and error prone, I'm also submitting it for Outsystems support to have a look at.

Cheers,

Marcel 

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