How to get a JSON String from JSONObject? : <p>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.</p>

<p>I can write a method, I just cannot believe there isn't have a better solution.</p>

<pre><code>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" +
                "}";


}
</code></pre>
