I have some string in xml format and need to convert it into JSON format. I have read Quickest way to convert XML to JSON in Java but we can't use any external libs but standard Java.
Is there any simple or good way to achieve this without any third party libs?
Here is the xml string looks like:
<container>
<someString>xxx</someString>
<someInteger>123</someInteger>
<someArrayElem>
<key>1111</key>
<value>One</value>
</someArrayElem>
<someArrayElem>
<key>2222</key>
<value>Two</value>
</someArrayElem>
</container>
Need change it into:
{
"someString": "xxx",
"someInteger": "123",
"someArrayElem": [
{
"key": "1111",
"value": "One"
},
{
"key": "2222",
"value": "Two"
}
]
}