-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
The XML.toString() function seems to ignore keys when they are called "content", strange but true...(?)
import org.json.JSONObject;
import org.json.XML;
public class JSONbug {
private static void test(String jsonString) {
JSONObject json = new JSONObject(jsonString);
System.out.print("Given the JSON object:");
System.out.println(json);
System.out.print("which has the keys: ");
System.out.println(json.keySet());
System.out.println("If we convert to XML, we get: ");
System.out.println(XML.toString(json));
}
public static void main( String[] args ) {
System.out.println("Test 1: If a JSON key is 'content', things break:");
test("{\"content\": \"test this\", \"status\": \"error\"}");
// test this<status>ok</status>
System.out.println("-----------------");
System.out.println("Test 2: keys like 'contents' work fine:");
test("{\"contents\": \"test this\", \"status\": \"ok\"}");
// <contents>test this</contents><status>ok</status>
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels