ajson
ajson copied to clipboard
JSON to ABAP - Single JSON Document vs JSON Array Issues
After updating ZCL_AJSON to version 1.19 we have run into an issue that might be a possible bug in the ZCL_AJSON. In our case we work with student data and return a json payload containing a deep structure student document. We have two methods to get this data. 1) get a single document that contains a deep structure as a single item document or return an array of documents.
Issue: In the working scenario the ZCL_AJSON libs is returning the "email" field as a type C, in the error scenario the libs is returning type H based on if the document is presented as a single json document or an array.
The error we are now getting after the upgrade of ZCL_AJSON is "Unsupported target for value" when we use a single json document.
When we use the same json document but placed into an json array the issue is not present. The behavior was only observed after the upgrade
Scenario #1 - Get Student returns a single JSON document which results in an error in processing due to the "email" node. It would seem it's due to the node name "email" being used for both the parent and child node. (See Below)
Scenario #2 - Get Students multiply items - The results are returned as an array of student records in this case the code processes as expected without an issue.
Single document
"email": [
{
"identifier": "CAMP",
"name": "CAMP",
"description": "Campus",
"contactType": "CAMP",
"email": "[email protected]"
},
{
"identifier": "OTHR",
"name": "OTHR",
"description": "Other",
"contactType": "OTHR",
"email": "[email protected]"
}
]
}
Array document
"email": [
{
"identifier": "CAMP",
"name": "CAMP",
"description": "Campus",
"contactType": "CAMP",
"email": "[email protected]"
},
{
"identifier": "OTHR",
"name": "OTHR",
"description": "Other",
"contactType": "OTHR",
"email": "[email protected]"
}
]
}
]
}