I have a complex JSON payload with nested arrays. I need to create a JSON spec to output the same payload as I have today so that if the sending system added any new fields, I want them to be dropped. I need this capability because in TIBCO's Business Works, I need this output to be parsed against an XSD that I have generated for this JSON payload. Unfortunately, if new fields arrive in the JSON payload, the transform to XML using the XSD fails as it does a strict compare and there is currently no option to get around it in Business Works.
My example of JSON is
{
"items": [
{
"id": "000fd75c2b2fd30cadaae94c532d82f2408d95454996941002d8c8088157d03b",
"sourceIdentifier": {
"dataPartitionId": "877307a0-b5f5-4a01-9d4b-9fead6bcf788",
"id": "103357"
},
"birthDate": "YYYY-MM-DD",
"gender": {
"codings": [
{
"code": "248153007",
"display": "Male",
"system": "2.16.840.1.113883.6.96"
}
],
"sourceCodings": [
{
"code": "248153007",
"display": "Male",
"system": "2.16.840.1.113883.6.96"
}
],
"text": "Male"
}
}
],
"totalResults": 1,
"firstLink": "xyz",
"lastLink": "abc"
}
I want a JOLT spec that goes down and specifies each of the child elements of the above payload. I have this simple spec below, but if the sending app added a new field it appears in the output as well and that is a problem for me.
[
{
"operation": "shift",
"spec": {
"items": "items"
}
}
]
Any help is appreciated. Thanks.
To silently filter fields from the JSON string that are unknown to BusinessWorks (which means they are not defined in the XSD used by BusinessWorks) you can use the 'ignore additional JSON fields' option introduced in BW 6.6.1.
See below extract from the release notes :
Support is added to ignore additional JSON fields when processing a schema
For the other part of your question you can use the following Studio feature : . Right click on the 'Schema' folder . Select 'News -> XML Schema File from JSON Payload'
But this approach has some limitations and I don't think it would manage arrays.