I have to convert xml code to Json. I have tried to use this code:
public String getJSON(String toConvert) {
String jsonString = null;
try {
JSONObject xmlJSONObj = XML.toJSONObject(toConvert);
jsonString = xmlJSONObj.toString();
} catch (JSONException je) {
System.out.println(je.toString());
}
return jsonString;
}
It works, but only for a short String. What should I do to make it work with a very long String?
It is not problem with convert xml to json. That part (method getJson
) is correct. constant string too long
java compile error is the problem. You can resolve it, look at that question and answers .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.