i have the following json-string:
{result:{"id":"1234","pages": [{"Id":50,"data":"{\"name\":\"name1\",\"description\":\"description1\"}"}],"errors":[] }}
which i want to convert to xml. I have tried several methods to convert, one of which is decribed here: Java implementation of JSON to XML conversion :
JSONObject o = new JSONObject(jsonString);
String xml = org.json.XML.toString(o);
the result of this is:
<result><id>1234</id><pages><data>{"name":"name1","description":"description1"}</data><Id>50</Id></pages></result>
or formatted:
<result>
<id>1234</id>
<pages>
<Id>50</Id>
<data>{"name":"name1","description":"description1"}</data>
</pages>
</result>
obviously the data in 'data' is converted to a string. Actually what I want is a structure like this, where the content of the 'data' block is converted to tags:
<result>
<id>1234</id>
<pages>
<Id>50</Id>
<data>
<name>name1</name>
<description>description1</description>
</data>
</pages>
</result>
i know this was the result if the json string would be
{result:{"id":"1234","pages": [{"Id":50,"data":{"name":"name1","description":"description1"}}],"errors":[]}}
but unfortunatelly i can not change that.
So does anyone know about a method to convert
{result:{"id":"1234","pages": [{"Id":50,"data":"{\"name\":\"name1\",\"description\":\"description1\"}"}],"errors":[] }}
to
<result>
<id>1234</id>
<pages>
<Id>50</Id>
<data>
<name>name1</name>
<description>description1</description>
</data>
</pages>
</result>
in java?