Skip to Content
0

How does a SAP PO 7.5 rest adapter convert repeated XML segments to JSON array ?

Jul 08, 2017 at 07:40 AM

140

avatar image

Hello Experts,

Can any of you kindly explain how a rest adapter converts repeated segments in the xml to JSON array.

kindly find the JSON example attached. I want the xml to be converted like that.

What will be xml output at message mapping to convert like that.

Will there be any additional configuration that i have to do in the rest adapter for this ?

Is there any way to see the JSON output from rest adapter, other than using NWA logs or XPI inspectors ? i dont have access to both.jsonarray.txt

Thanks,

Nirmal

jsonarray.txt (731 B)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Muniyappan Marasamy Jul 10, 2017 at 05:56 AM
1

how to convert to json array using adapter configuration, check Vadim Klimov's blog

https://blogs.sap.com/2016/01/13/rest-adapter-in-sap-pipo-enhanced-xmljson-conversion/

if you want how will your xml output should look like, then convert your json into xml using below link.

https://codebeautify.org/jsontoxml it will be something like below.

root tag can be your message type name.

<?xml version="1.0" encoding="UTF-8" ?>
<root>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>CM2</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>D12</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>D51</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>E1N</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>ED5</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>EK1</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>EO1</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>EZ5</codeNumber>
	</otherCodes>
	<otherCodes>
		<avdCodeType>0</avdCodeType>
		<codeNumber>EZ7</codeNumber>
	</otherCodes>
</root>

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the inputs Muni M. I understood vadim's blog. But i don't have the xml/json namespace mapping settings in my rest adapter. I guess i have update the PI system with the sap note.

0