Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
vinaymittal
Contributor

Introduction


We all have come across scenarios where while Integrating between SAP and third party systems we have to convert from

JSON to XML - So that SAP understands the JSON data being sent by the third party

or from

XML to JSON -so that the third party system that understands(or prefers to Understand) only JSON can consume the XML data being sent by SAP.

 

You should not do these conversions without knowing the supported JSON Conventions by the third party system and then comparing it with SAP CI standard JSON convention as it would be as ridiculous as generating a XSD out of an XML via same online tool.

SAP CI XML to JSON convertor by default supports Rabbit Fish Convention while most of the platforms accept Badger Fish JSON Convention.

 

Overview


Let's understand and educate ourselves of the differences between the various JSON conventions.

There are 4 major JSON conventions

  1. Badger Fish - Most popular but memory intensive in terms of storage

  2. Rabbit Fish - Best representation of fields and Attributes

  3. Ray Fish

  4. Plain JSON


To understand the difference let's have a look at some examples




























JSON Convention JSON Representation XML Data
Badger Fish
{
"FirstLevel": {
"@Source": "InService",
"Task": {
"@nodeAttribute": 234,
"JobNumber": {
"$": "J918290"
},
"JobDescription": {
"$": "This is a temp job"
},
"LineOfBusiness": {
"$": "Supply Restoration"
},
"TaskType": {
"@elementAttribute": "eA",
"$": "Miscellaneous"
}
}
}
}


<FirstLevel Source="InService">
<Task nodeAttribute="234">
<JobNumber>J918290</JobNumber>
<JobDescription>This is a temp job</JobDescription>
<LineOfBusiness>Supply Restoration</LineOfBusiness>
<TaskType elementAttribute ="eA">Miscellaneous</TaskType>

</Task>
</FirstLevel>

Rabbit Fish
{
"FirstLevel": {
"@Source": "InService",
"Task": {
"@nodeAttribute": 234,
"JobNumber": "J918290",
"JobDescription": "This is a temp job",
"LineOfBusiness": "Supply Restoration",
"TaskType": {
"@elementAttribute": "eA",
"$": "Miscellaneous"
}
}
}
}​


<FirstLevel Source="InService">
<Task nodeAttribute="234">
<JobNumber>J918290</JobNumber>
<JobDescription>This is a temp job</JobDescription>
<LineOfBusiness>Supply Restoration</LineOfBusiness>
<TaskType elementAttribute ="eA">Miscellaneous</TaskType>

</Task>
</FirstLevel>

Ray Fish
{
"#name": "FirstLevel",
"#text": null,
"#children": [
{
"#name": "@Source",
"#text": "InService",
"#children": []
},
{
"#name": "Task",
"#text": null,
"#children": [
{
"#name": "@nodeAttribute",
"#text": 234,
"#children": []
},
{
"#name": "JobNumber",
"#text": "J918290",
"#children": []
},
{
"#name": "JobDescription",
"#text": "This is a temp job",
"#children": []
},
{
"#name": "LineOfBusiness",
"#text": "Supply Restoration",
"#children": []
},
{
"#name": "TaskType",
"#text": "Miscellaneous",
"#children": [
{
"#name": "@elementAttribute",
"#text": "eA",
"#children": []
}
]
}
]
}
]
}


<FirstLevel Source="InService">
<Task nodeAttribute="234">
<JobNumber>J918290</JobNumber>
<JobDescription>This is a temp job</JobDescription>
<LineOfBusiness>Supply Restoration</LineOfBusiness>
<TaskType elementAttribute ="eA">Miscellaneous</TaskType>

</Task>
</FirstLevel>

Plain JSON
{
"FirstLevel": {
"Source": "InService",
"Task": {
"nodeAttribute": 234,
"JobNumber": "J918290",
"JobDescription": "This is a temp job",
"LineOfBusiness": "Supply Restoration",
"TaskType": {
"elementAttribute": "eA",
"$": "Miscellaneous"
}
}
}
}​


<FirstLevel Source="InService">
<Task nodeAttribute="234">
<JobNumber>J918290</JobNumber>
<JobDescription>This is a temp job</JobDescription>
<LineOfBusiness>Supply Restoration</LineOfBusiness>
<TaskType elementAttribute ="eA">Miscellaneous</TaskType>

</Task>
</FirstLevel>


 

 

 

As you can see Rabbit Fish is the most meaningful and complete representation of attributes and nodes. The only possible way to achieve selective JSON to XML conversion is via XSLT mapping (for formats other than RabbitFish) as SAP CI only supports RabbitFish at the moment I hope that we should get radio buttons in the UI to chose the Convention soon.

If you would like to explore these JSON Conventions by converting your XML's to these JSON formats feel free to use this online tool that I built on UtilityArena

 

PS: I have no idea why all the JSON Conventions end in the word "Fish".
2 Comments
Labels in this area