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!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Dear SAPiens,

There are some limitations while using JSON to XML Conversion in built function. One of them is -->

"The root JSON object must contain exactly one member. If the root JSON object contains more than one member (for example, {"a":"avalue","b":"bvalue"}), a is thrown. If the root JSON object is empty ({}), a is thrown. As of cluster version 1.21, a JsonXmlException or IllegalStateException (for {}) is thrown."

--> For this limitation apply point no.2 directly

"JSON texts that start with an array (for example, [{"a":{"b":"bvalue"}}] ) are not supported. The JSON text must start with a JSON object such as {{"a":{"b":"bvalue"}}}. A is thrown. As of cluster version 1.21, a JsonXmlException is thrown."

--> Follow below steps

I have gone through many threads on SCN and got pretty good understanding about the issue and how to fix this. Thanks to sriprasad.shivarambhat for his valuable inputs on CPI thread. Below I am sharing my study Iflow which is handling such scenarios.  P.S. - This is to explore the issue and not a real-time case.

Below is the brief of different steps from the IFlow: -

  1. Content modifier(A) to get the input JSON file which is starting with [ ]

  2. Content Modifier(B) to add root and elements in the JSON payload (Another way is to write script)

  3. JSON to XML Converter in built function

  4. Content modifier(C) to save XML file in Body

  5. XML to JSON Converter in built function

    1. Only Suppress JSON root element available

    2. Element will be added in the payload

    3. All fields will be considered as String

  6. Groovy Script(1) to remove element from JSON file and convert string into integer

  7. Content modifier(D) to save JSON file


1. Content Modifier(A): - Input JSON File

{"id": 1},
{"id": "OpenNew", "label": "Open New"},
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
{"id": 10000},
{"id": "Pause"},
{"id": "Mute"},
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}


2. Content Modifier(B): -


3. JSON to XML Converter

4. Content Modifier(C)

This step is just to hold and check payload in XML format

5. XML to JSON Converter: -

6. Groovy Script(1): - This code will help to remove element from the JSON payload and convert string      to Integer
import java.util.HashMap;

def Message processData(Message message)
def JSON = message.getBody(String)
def JSON_Rem = JSON.substring(11,JSON.length()-1)
String output = JSON_Rem.replaceAll("\"(\\d+)\"", "\$1");
return message;

7. Content modifier(D) to save JSON file

References: -

2521044 - CPI: XML to JSON Converter treats Integer as String


Thanks & Regards,

Rashmi Joshi
Labels in this area