-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Trying to convert JSON data into XML string using the below logic of code snippet. But, output xml has a JSONObject being displayed after "content" attribute as show below. Any suggestions.?
# input.json:
{
"id": "0001",
"type": "donut",
"name": "Cake",
"payload": {
"uname":"David"
"content": {
"batter": [
{
"id": "1001",
"type": "Regular",
"mode": [
"rel",
"don"
]
}
]
}
}
}
jsontoxml.java:
org.json.JSONObject jsonObject = new org.json.JSONObject(jsonData);
string xml="<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n<"+root+">" + org.json.XML.toString(jsonObject) + "</"+root+">
output.xml:
<?xml version="1.0" encoding="ISO-8859-15"?>
<root>
<id>0001</id>
<type>donut</type>
<name>Cake</name>
<payload>
<uname>David</uname>
{"batter": [{"id": "1001","type": "Regular","mode": ["rel","don"]}]}
</payload>
</root>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels