

Also, delete the namespace tag from the JSON structure and set node5 as JSON ArrayĮxample3: Remove the level 1 i.e the root tag level, always keep node1 as JSON Array (even if one record is found) and hide node1 key and delete the namespace attribute. Below are a few examples that will help you understand the same.Įxample1: If the default values of the parameters are set.Įxample2: Hide the root tag and send data as JSON Array. Now let’s understand how you have to set the parameter values.

Setting this to true will result in all the numbers (integer, float, long, short, double) to be in double-quotes in the output JSON format.If you want to covert all the numbers to string in the output JSON structure, then set this variable as ‘true’.If you don’t want to delete any entries, then set the field as 0.LAST_LEVEL_TO_KEEP = 2 (This will remove first 2 levels from the XML/JSON structure) Value 1 implies removing the root node completely from the structure and keep its child node in the JSON structure.Value 0 implies to not delete any level.If you wish to delete the initial tags from XML hierarchy and retain the child nodes, then pass the level number to this field.If you don’t want to delete any entries, then keep the field blank.If you wish to delete a tag and its value from the JSON structure, then pass all such tag names as a list separated by commas to this field.If you don’t want to hide any keys in JSON, then keep the field blank.If you wish to hide the tag name and pass only the equivalent values to JSON structure, then pass all the tag names as a list separated by commas to this field.If you don’t want to convert any node to array in JSON, then keep the field blank.All tags including the root tag that are to be converted into an array can be passed here as a list separated by commas.Step 6:- (Optional) If you are using REST channel, don’t forget to set the data as JSON in the Receiver channel Step 5:- Assign values to these parameters in the Integrated Configuration as required Step 4:- Define Binding for the JAVA mapping in operation mapping as below: NUM_TO_STRING – Simple Type – xsd:string.LAST_LEVEL_TO_KEEP – Simple Type – xsd:int.DELETE_ENTRY – Simple Type – xsd:string.Step 3:- Define the 5 Import parameters in operation mapping. Step 2:- Use the java mapping in your operation mapping So do import the orgXmlJson jar file also. Please note the Java mapping uses java library to convert XML to JSON, so if it’s not in your SAP library, you will receive missing ‘’ error. Import the 2 jar files in SAP ESR as Imported Archives.
#Convert string to json java zip file
You can directly download the zip file from here and unzip it. This can be used in any SAP PI/PO version.Įxamples are illustrated further below after the implementation section. This blog focus on XML to JSON conversion using Java Mapping and also provides the liberty to play around with the structure. Hence, I have implemented a Generic Java Mapping that can be used to achieve this and many other tasks.

The Custom XML to JSON Conversion bean also doesn’t help much here, especially if you wish to remove a node from the JSON structure. However, this liberty isn’t available on SAP PI versions 7.4 & below. However, there are many restrictions on it in SAP PI/PO.īesides, in SAP PO 7.5 we can easily remove a key name by listing the tags in ‘setIgnoredElements’ on REST Receiver Channel.

We can easily convert XML to JSON on the REST channel. I was recently trying to convert XML To JSON in the below format in SAP 7.4 and also trying to remove certain tags from the XML structure and force a few nodes as JSON Array.
#Convert string to json java update
Update 10th July 2020 – Added functionality to convert numbers to String using the NUM_TO_STRING parameter.
