General Discussions

Discuss any topics that are not product-specific here.
SOLVED

XML to JSON Conversion

nadiyanazeer
7 - Meteor

Hi , I am new to Alteryx and facing issues with converting XML to JSON .Please help

XML

<?xml version="1.0" encoding="UTF-8"?>
<root>
<person>
<name>XX</name>
<age>30</age>
</person>
<person>
<name>YY</name>
<age>25</age>
</person>
</root>

 

To convert to JSON in the below format

{
"root": {
"person": [
{
"name": "XX",
"age": "30"
},
{
"name": "YY",
"age": "25"
}
]
}
}

5 REPLIES 5
Luke_C
17 - Castor

Hi @nadiyanazeer 

 

Here's an example of how. 

 

  1.  Parse the XML
  2. Transpose the data
  3. Build out the json fields 
  4. Use the json build tool

 

 

 

Capture.PNG

caltang
17 - Castor
17 - Castor

Thanks for sharing @Luke_C ! I'm bookmarking this for future reference.

 

@nadiyanazeer kindly mark Luke's suggestion as the accepted solution if it fits your needs. Thanks!

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
nadiyanazeer
7 - Meteor

Thankyou  @Luke_C for your response with workflow and detailed steps! Its much appreciated. One quick query .When i tried it as a JSON file , I am getting it in the below format .

[
    {
        "JSON": "{\"root\":{\"person\":[{\"name\":\"XX\",\"age\":\"30\"},{\"name\":\"YY\",\"age\":\"25\"}]}}"
    }
]
Luke_C
17 - Castor

Hi @nadiyanazeer 

 

That's interesting. I can't say I've ever output to a json file, usually the JSON I create feeds into another API or downstream process within the workflow. That said, take a look at the solution to this post for an alternative approach: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Issue-with-output-to-json-addi...

 

nadiyanazeer
7 - Meteor

Thankyou  @Luke_C for the above solution! This will definitely help me ! Cheers !

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels