Hi everyone,
I'm working on an integration service module in OutSystems, consuming a REST API provided by a third-party vendor. I'm facing a common challenge: the JSON response structure for one specific API endpoint can have a particular JSON key (in the nested JSON structure) with variable data types for its value (e.g., text, numbers, decimals, booleans, objects, or lists of any of these).
The Problem:
In the JSON response from this external API endpoint, a specific field ("Value" is my key in question example key, but this could apply to any field name) can contain different JSON data types depending on the context or associated metadata. For instance, my "Value" field might come back as:
OutSystems' JSON Deserialization action, when mapping to a defined Structure, expects a consistent, single data type for each attribute.
My attempts:
After some research, I found that the OnAfterResponse Handler in the REST API method seems like the ideal place to implement this transformation. My initial thought was to use Regex_Replace from the Text extension to capture and modify these varying values. However, due to the complexity of JSON's nested structures and diverse data types, I've struggled to create a robust regex that consistently captures all possibilities.
I've run into issues with:
My ask:
Could someone please point me to the right direction as to how to handle this? I would appreciate some more detailed guidance since I am a relatively new OutSystems developer. Much appreciated!
Example:
Here's an example of the kind of JSON structure I'm dealing with, showing the Value field's variability:
{
"TotalCount": 1,
"Objects": [
"ParentObject": {
"ArtifactID": 10349035
},
"FieldValues": [
"Field": {
"ArtifactID": 5435435,
"FieldCategory": "Generic",
"FieldType": "FixedLengthText",
"Guids": [],
"Name": "MarketNumber",
"ViewFieldID": 222344
"Value": [
"REL0000000132",
"REL0000000133"
]
"ArtifactID": 1342343,
"FieldType": "SingleChoice",
"Name": "Recipient",
"ViewFieldID": 2222
"ArtifactID": 434355,
"Guids": [
"MyplaceholderGUID"
],
"Name": "Extended Email Address"
"ArtifactID": 2222222,
"MyplaceholderGUID2"
"Name": "Extended Email Address1"
}
"ArtifactID": 111111,
"Name": "website",
"ViewFieldID": 1003245
"Value": "microsoft.com"
"ArtifactID": 190090,
"Guids": []
"IDWindow": [],
"CurrentStartIndex": 1,
"ResultCount": 1,
"ObjectType": {
"ArtifactID": 19999,
"Name": "Document",
"MyGuidforDoc"
"ArtifactTypeID": 10
"RankWindow": []
So this is a problem but it happens more often that I like, one of the possible solution I found is handle the response as text, and then you can handle depending of the case different structures to deserialize in the action or in an upper layer, but for that you need to know which structures use.I hope it helps