For example, I want to print it as below, instead of one single line. This is a JSON string. By default, myJsonObject.toString() is a one-line String. Is there some method from org.json.JSONObject that can directly output this formatted form?
{
"name":"John",
"age":30,
"cars": [
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },
{ "name":"BMW", "models":[ "320", "X3", "X5" ] },
{ "name":"Fiat", "models":[ "500", "Panda" ] }
]
}