I would like to convert XML to JSON.
Currently, I make this with the lib org.json :
JSONObject jso = XML.toJSONObject(xmlStr);
However, if the XML contains number fields, I would like to have only String fields in the JSONObject
.
For example:
The XML file is :
<ID>3</ID>
<NAME>ApplicationName</NAME>
The org.json permits me to have:
{
"ID" : 3,
"Name" : "ApplicationName"
}
The final result has to be :
{
"ID" : "3",
"Name" : "ApplicationName"
}
I resolve mt problem by using the latest version of org.json.
There is a methode to do this :
The boolean is using to keep the string fields.