cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI XML to JSON conversion: Force output as an Array

filipe_rieger
Explorer
10,612

Hi,

I am passing following XML to the XML to Json converter:

<ns1:AddressCurationResponse xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
	<CurationInformation>
		<item>
			<Changes>
				<item>
					<ACTION>xyz</ACTION>
					<FIELD>xyz</FIELD>
					<MESSAGE>xyz</MESSAGE>
				</item>
				<item>
					<ACTION>xyz</ACTION>
					<FIELD>xyz</FIELD>
					<MESSAGE>xyz</MESSAGE>
				</item>
			</Changes>
			<PostalAddress>
				<CityName>xyz</CityName>
				<DistrictName>xyz</DistrictName>
			</PostalAddress>
			<Rating>
				<SCORE>1</SCORE>
				<ACCURACYINDICATOR>1</ACCURACYINDICATOR>
				<CURATIONLEVEL>1</CURATIONLEVEL>
			</Rating>
		</item>
	</CurationInformation>
</ns1:AddressCurationResponse>


Now I want the converter to force output the element ns1:AddressCurationResponse/CurationInformation/item as a json array with [] instead of {}.In the converter there is the option to use json streaming:

But upon saving, its telling me that the table should not be empty:

What am I missing?

The same question was also asked here, but the solution was not shown unfortunately:

https://answers.sap.com/questions/12689222/get-xml-element-in-json-array-using-xml-o-json-con.html

Accepted Solutions (1)

Accepted Solutions (1)

manoj_khavatkopp
Active Contributor

Hi Filipe,

I tried with the given XML and below is the output from XML-JSON converter.I had the same error of "Table may not contain empty rows" , i still went and deployed the Iflow . Just close the iflow and reopen it ,the error disappears.

And note as you are explicit mentioning XML to JSON conversion via enabling streaming option , make sure you mention the other paths as well which need to be and array to form a valid JSON in . In you case for the above payload even : / AddressCurationResponse/CurationInformation/item/Changes/item

also needs to be an array.

Converter:

OutPut:

{"AddressCurationResponse":{"CurationInformation":{"item":[{"Changes":{"item":{"ACTION":"xyz","FIELD":"xyz","MESSAGE":"xyz"},"item":{"ACTION":"xyz","FIELD":"xyz","MESSAGE":"xyz"}},"PostalAddress":{"CityName":"xyz","DistrictName":"xyz"},"Rating":{"SCORE":"1","ACCURACYINDICATOR":"1","CURATIONLEVEL":"1"}}]}}}

Answers (2)

Answers (2)

filipe_rieger
Explorer
0 Kudos

Hi Both,

you are right. This is just a display bug.

Thanks a lot for your prompt feedback!!

engswee
Active Contributor
0 Kudos

Hi Filipe

I've encountered it before and I think that is a false error. Try saving, then exit the IFlow ignoring the error. Then when you reopen the IFlow, the error would no longer be there. Try deploying the IFlow then and test it with a message.

Regards

Eng Swee