Reputation: 343
I'm converting a XML
string to JSONObject
using following method:
XMLSerializer xml = new XMLSerializer();
JSONObject json = (JSONObject) xml.read(input);
but after the conversion happened some tags are not included in JSONObject
. missing tags are exactly the same tags that included in JSONObject
the only difference is attributes inside the tags are different. can someone tell me what is happening with the conversion.
here are the tag that includes in JSON
<entry urlName="Dir"
utf8Name="Dir"
type="directory"
changeTimeMilliseconds="1373284160872.00"
changeTimeString="2013-07-08T17:19:20+0530"
state="created"/>
and this is the tag skip from convertion
<entry urlName="c_samples.zip"
utf8Name="c_samples.zip"
type="object"
size="453"
hashScheme="SHA-256"
hash="9AAA2B203F75ED679F133C1A26BA9BB04CF12466DF0670DEC3CD587ED5FF0A27"
retention="1438317494"
retentionString="7/31/2015 10:08AM"
retentionClass=""
ingestTime="1375244240"
ingestTimeString="7/31/2013 9:47AM"
hold="false"
shred="true"
dpl="1"
index="false"
customMetadata="true"
customMetadataAnnotations="default;453"
version="88015631368193"
replicated="false"
changeTimeMilliseconds="1375260472887.00"
changeTimeString="2013-07-31T14:17:52+0530"
owner="owner"
domain=""
hasAcl="false"
state="created"/>
Upvotes: 0
Views: 731
Reputation: 343
found a solution from changing converting method. earlier I used net.sf.json.JSONObject
to create the JSONObject
and net.sf.json.xml.XMLSerializer
to do the convertion. I switched to org.json.JSONObject
and org.json.XML
and used
JSONObject json = XML.toJSONObject(input);
method. it gave me the complete set of tags I want to convert. :)
Upvotes: 1