Skip to Content

Converting XML to JSON using Content Modifier or Script

Dear Experts,

I am having issue in Converting XML to JSON.

The format expected by Customer. Please let me know know how I can achieve it using Content modifier or Script.

I did some settings and got only first node of Customer and not able to get second and Subsequent nodes.

Please advise to fix the issue. The content Modifier screen shot is added in the attachmeny

Requested Output:

{
"name":"Lead time request Project",
"salesOrganisationName":"1000",
"number":"94895",
"Customers":[
{
"Country":"IN",
"HouseNumber":"3",
"Number":"100003535",
"PostalCode":"M3 2HW",
"Street":"Parsonage",
"CustomerType":"Installer",
"Name":"Adam Mcloughlin"
},
{
"Country":"LX",
"HouseNumber":"3",
"Number":"100003535",
"PostalCode":"M3 2HW",
"Street":"Parsonage",
"CustomerType":"Dealer",
"Name":"Adam Mcloughlin"
}
]
}

The Content Modifier Body I have user as below:

{
"name":"${property.name}",
"salesOrganisationName":"${property.salesOrganisationName}",
"number":"${property.number}",
"Customers":[
{
"Country":"${property.Country}",
"HouseNumber":"${property.HouseNumber}",
"Number":"${property.Number}",
"PostalCode":"${property.PostalCode}",
"Street":"${property.Street}",
"CustomerType":"${property.CustomerType}",
"Name":"${property.Name}"
}
]
}

After formatting with the above logic the the Output I received.

{
"name":"Lead time request Project",
"salesOrganisationName":"1000",
"number":"94895",
"Customers":[
{
"Country":"IN",
"HouseNumber":"3",
"Number":"100003535",
"PostalCode":"M32HW",
"Street":"Parsonage",
"CustomerType":"Installer",
"Name":"Adam Mcloughlin"
}
]
}

Thanks & Regards

capture.pngVijay S B

capture.png (18.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Hi Vijay

    Please post your input XML as well. If you use the CODE formatting button, indentation is kept, which helps readability.

    Regards,

    Morten

  • Hi Morten,


    Please find the input xml below

    <?xml version="1.0" encoding="UTF-8"?><Root><name>Lead time request Project</name><salesOrganisationName>1000</salesOrganisationName><number>94895</number><Customers><Country>IN</Country><HouseNumber>3</HouseNumber><Number>100003535</Number><PostalCode>M3 2HW</PostalCode><Street>Parsonage</Street><CustomerType>Specifier</CustomerType><Name>Adam Mcloughlin</Name></Customers><Customers><Country>LX</Country><HouseNumber>3</HouseNumber><Number>100003535</Number><PostalCode>M3 2HW</PostalCode><Street>Parsonage</Street><CustomerType>Installer</CustomerType><Name>Adam Mcloughlin</Name></Customers></Root>

    Thanks & regards

    Vijay S B

  • Follow
  • Get RSS Feed

1 Answer

  • Mar 28 at 12:08 AM

    Hi Vijay,

    I am having same requirement. Can you share the details how you acheived it.

    Regards,

    Aswini.

    Add comment
    10|10000 characters needed characters exceeded