How to convert xml to json format

asked 2018-12-18 06:42:55 -0600

Sharan gravatar image

I have a question on xml to json transform. I need to build a pipeline which will read an xml file periodically using HTTP client and after that need to add some field to it and post it to a HTTP rest api.

HTTP client using get -> xml-to-json-converter/ add new field to it ->Http post url using json

Can you provide some guidance on which stage to use for xml-to-json converter Below is my xml body

<messageheader> <messageid>*</messageid> <messagetimestamp>2018-11-22T06:01:21Z</messagetimestamp> <senderid>_DAO_SCA</senderid> <receiverid>_DAO</receiverid> <messagetype>PO_</messagetype> <correlationid/> </messageheader> <transactionid>**</transactionid> <ponumber/> <version>1</version> <referencenumber type="ASN">*</referencenumber> <tolocation>SCA</tolocation> <partlist> <part> <partid>M67RH</partid> <vendorid>70710</vendorid> <vendorloc>70710</vendorloc> <quantity>216</quantity> </part> </partlist> </tns:poreceive>

Wanted to convert the above xml to JSON format and append it with few parameters below

appName": "*", "appUser": "ALL", "businessIdentifier": "", "domain": "", "environment": "Dev", "event": "SERVICE", "globalTransactionId": "*", "hostname": "hostName-NXT", "payload": "", "serviceName": "*", "serviceVersion": "0.0.1-SNAPSHOT", "status": "INFO", "step": "DEFAULT", "threadId": "string", "transactionMode": "string"

edit retag flag offensive close merge delete