|
|
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
import org.json.XML;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
@ -158,5 +161,20 @@ public class JsonUtil {
|
|
|
|
|
sb.insert(0, '\n');
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String xmlStr =
|
|
|
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
|
|
|
|
"<note>\n" +
|
|
|
|
|
"<to>Tove</to>\n" +
|
|
|
|
|
"<from>Jani</from>\n" +
|
|
|
|
|
"<heading>Reminder</heading>\n" +
|
|
|
|
|
"<body>Don't forget me this weekend!</body>\n" +
|
|
|
|
|
"</note>";
|
|
|
|
|
|
|
|
|
|
JSONObject json = XML.toJSONObject(xmlStr);
|
|
|
|
|
String jsonStr = json.toString(4);
|
|
|
|
|
System.out.println(jsonStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|