Convert XML to JSON

I have some Data in xml-forma and would like to bootstrap my project with this data.

What is best/easiest to convert from xml to json-object?

I tried some Javascript based libraries, but he most of them failed, because Nashorn does not support all of the features these libs use.

Is there already a lib for that ?

We have been converting XML to JSON in Java using this library: GitHub - stleary/JSON-java: A reference implementation of a JSON package in Java.

You can do something like this in Java:

String json = org.json.XML.toJSONObject(xml).toString();

Or maybe something like this in JavaScript:

const xmlParser = __.newBean("org.json.XML");

const myJson = JSON.parse(xmlParser.toJSONObject(myXmlString).toString());

– Tom Arild

Looks easy :slight_smile:
I already was aware of this library - unfortunately the documentation is not good :frowning:

But with your help - I will manage this !

Thank you!

@tom Update: it works :blush:

1 Like