Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Atom (XML) to JSON

Do someone have a way to convert data from Atom (XML) format to JSON? I would prefer a free online tool to do this. I cannot post the data i am trying to convert online: As it contains sensitive information.

like image 385
Alexander Johansen Avatar asked Dec 28 '25 23:12

Alexander Johansen


1 Answers

"Convert XML to JSON" is simple to say, but XML and JSON are different structural paradigms. If your XML document looks like:

<a>
    <b>foo</b>
    <c prop="value">bar</c>
</a>

... how do you represent that in JSON? There are lots of questions, like:

  • Does ordering matter? (Object properties in JSON are unordered, so after conversion there is no way to tell if <c> came before or after <b>)
  • If there is only one <b>, does that mean it's a single-item array, or just an object?
  • How do you represent attributes? Does the convertor flip between plain strings (for "b") and objects with extra properties (for "c") depending on whether attributes are defined?

Each "XML to JSON convertor" I've seen has taken a slightly different approach to this, so there is no "standard" behaviour to rely on.

So, for a complete answer, I think you need to give a clearer idea of what you want your JSON ATOM format to look like.


If you just want something, and you'll work around whatever you get, then you might be able to do this with a service like Yahoo Pipes (example here, I'm sure there are more).

However, you are at the whim of whatever actual convertor is being used behind the scenes, which might have odd behaviours (e.g. one day your source feed adds an attribute, and your output changes dramatically).

like image 89
cloudfeet Avatar answered Dec 31 '25 13:12

cloudfeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!