Skip to Content
0

Convert XML to Json only Body

Oct 29, 2017 at 03:13 AM

40

avatar image
Former Member

Hello Dear Gurus.

I have an scenario Proxy to JSON ,I would like to convert this XML to JSON

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Material_List xmlns:ns0="urn:test:test01">
	<products>
		<baseUnit>UN</baseUnit>
		<externalCode>000000000000200007</externalCode>
		<length>0.000</length>
		<materialGroup>20015</materialGroup>
		<name>Cozumel 1</name>
		<service>false</service>
		<volume>0.000</volume>
		<weightGross>0.000</weightGross>
		<weightNet>0.000</weightNet>
		<weightUnit>KG</weightUnit>
		<width>0.000</width>
		<pathPOS>products</pathPOS>
	</products>
	<products>
		<baseUnit>UN</baseUnit>
		<externalCode>000000000000200008</externalCode>
		<length>0.000</length>
		<materialGroup>20015</materialGroup>
		<name>Cozumel 2</name>
		<service>false</service>
		<volume>0.000</volume>
		<weightGross>0.000</weightGross>
		<weightNet>0.000</weightNet>
		<weightUnit>KG</weightUnit>
		<width>0.000</width>
		<pathPOS>products</pathPOS>
	</products>
</ns0:MT_Material_List>

I ned to convert and sent to REST Services like this.

[
{
"baseUnit": "UN",
"externalCode": "000000000000200007",
"length": "0.000",
"materialGroup": "20015",
"name": "Cozumel 1",
"service": "false",
"volume": "0.000",
"weightGross": "0.000",
"weightNet": "0.000",
"weightUnit": "KG",
"width": "0.000",
"pathPOS": "products"
},
{
"baseUnit": "UN",
"externalCode": "000000000000200008",
"length": "0.000",
"materialGroup": "20015",
"name": "Cozumel 2",
"service": "false",
"volume": "0.000",
"weightGross": "0.000",
"weightNet": "0.000",
"weightUnit": "KG",
"width": "0.000",
"pathPOS": "products"
}
]

I tried with many options like strip Outer element, but is only Header.


{"products":[{"baseUnit":"UN","externalCode":"000000000000200007","length":0.000,"materialGroup":20015,"name":"Test_Prueba1","service":false,"volume":0.000,"weightGross":0.000,"weightNet":0.000,"weightUnit":"KG","width":0.000,"pathPOS":"products"},{"baseUnit":"UN","externalCode":"000000000000200008","length":0.000,"materialGroup":20015,"name":"Test_Prueba2","service":false,"volume":0.000,"weightGross":0.000,"weightNet":0.000,"weightUnit":"KG","width":"0.000","pathPOS":"products"}]}
 

Can you help me that.?
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Oct 29, 2017 at 02:25 PM
0

Hi,

You sould convert it via channel REST, image below:

e the option "Stip Operation from Message and StripOuter Element", than you will remove root and first children.

In your case as I understand you want remove the Root of XML so mark only "Strip Operation From Message(Outer of Element).

I suggest also you change your structure like:

Than with "Strip Operation from Message" you will remove - MT_Material_List

<ns0:MT_Material_List xmlns:ns0="urn:test:test01">
    <array>
       </products>
    </array>
</ns0:MT_Material_List>

I hope to help.

Regards,

Viana.


capturar.png (8.4 kB)
capturar2.png (20.3 kB)
Share
10 |10000 characters needed characters left characters exceeded