I want to get a JSON String from the created JSONObject, which looks like a String when you want to create a JSONObject from that String.
I can write a method, I just cannot believe there isn't have a better solution.
import org.json.JSONObject;
public class JSONString {
JSONObject jsonObject = new JSONObject();
jsonObject.append("symbol", "AAPL");
jsonObject.append("price", "211.17");
// this is the String what I want to get from the jsonObject variable
String wantedResultString = "{\n" +
" \"symbol\" : \"AAPL\",\n" +
" \"price\" : 211.17\n" +
"}";
}