I have a JSON-file, which I want to convert to XML in JAVA to process some different things with the outcoming XML-structure. My file looks like this:
{
"published" : "2014-04-15T12:00:13.760Z",
"actor" : {
"objectType" : "person",
"id" : "a00906a9-d3e3-40b5-8ef2-9e1051828c09",
"displayName" : "Ashley Wessels"
},
"verb" : "floating_run",
"object" : {
"objectType" : "experiments",
"id" : "e9d9f71a-6c9e-4724-98d1-32dee57bb015",
"content" : [
{
"mass" : 10,
"volume" : 392.2,
"density" : 0.025497195308516064,
"fluid" : 1
},
{
"mass" : 150,
"volume" : 150,
"density" : 1,
"fluid" : 1
},
{
"mass" : 50,
"volume" : 50,
"density" : 1,
"fluid" : 1
},
{
"mass" : 50,
"volume" : 100,
"density" : 0.5,
"fluid" : 1
},
{
"mass" : 100,
"volume" : 50,
"density" : 2,
"fluid" : 1
},
{
"mass" : 400,
"volume" : 300,
"density" : 1.3333333333333333,
"fluid" : 1
}
]
},
"target" : {
"objectType" : "experiment",
"id" : "9383fbbe-e071-49b2-9770-46ddc4f8cd6e",
"displayName" : "Grundel experiment"
},
"generator" : {
"objectType" : "application",
"url" : "splash",
"id" : "04123e9e-14d0-447b-a851-805b9262d9a6",
"displayName" : "splash"
},
"provider" : {
"objectType" : "study",
"url" : "http://ift.tt/1qdISXL",
"id" : "0f8184db-53ba-4868-9208-896c3d7c25bb",
"displayName" : "SiswaGrundel"
},
"publishedClient" : "2014-04-15T12:17:03.902Z",
"publishedServer" : "2014-04-15T12:00:13.760Z",
"_id" : "534d1f4ddd5532e74400019f"
}
I used the org.json library and also tried some other libraries like JETTISON to create a xml-file from this guy but most of the `XML.toString()" methodd are not able to handle the JSONArray in this file. It just produces weird output of quotations marks etc. Is there a library which can handle this type of JSON structure? If not: how should I handle this file type?
No comments:
Post a Comment