Regarding Mapping JSON complex data type results in outsystems data types

Hi team REST API response for my time series data looks as mentioned belown where propertyValues is List<Dictionary<string, object>>


created Outsytems Structure to handle this response like this

 where PropertyValues is a propertyValue List & propertyValue.key is of type Text & propertyValue.Value is of type Decimal, but it is giving me the response with empty key & values


I can not provide Name is JSON tag for Key & value properties as it is a datetime in string format, Your help is much appreciated.
thanks

Hey,


The JSON you provided is quite dynamic, meaning it should be either formatted to something like this:


{

"propertyValues": [

{

"key": "6/14/2022 12:00:00 AM",

"value": 2.0

},

{

"key": "6/14/2022 12:30:00 AM",

"value": 2.0

},

{

"key": "6/14/2022 1:00:00 AM",

"value": 2.0

},

{

"key": "6/14/2022 1:30:00 AM",

"value": 2.0

}

]


}


Or you just build a more complex logic where you accept the JSON as plain text, not in a structured way and then perform operations (maybe using ardoJSON component) to get a structured record out of it. It's the way OutSystems interprets the JSON texts, it's difficult to automatically build dynamic structures based on variable keys.


Regards,

Bogdan

Hi,

to transform your source JSON to key value format you may want to give my forge component JSONata a try. It implements the JSON transformation and query language of www.jsonata.org. (and they have all the documentation on how to transform JSON). The documentation of the component includes a sample on how to transform dynamic key structures.

Hope that helps. I use it alot. For some reason i always have that complex, highly dynamic REST services šŸ˜’

Stefan

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