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?