I have JSON Object (Java), which is some key value pairs. My main objective is to use JSONObject.toString() and get the result in sorted orders w.r.t Keys.
Is there anyway by which I can achieve this.
jsonObject.put("z","A");
jsonObject.put("x", "B");
jsonObject.put("n", "C");
jsonObject.put("t", "D");`
Expected Output of jsonObject.toString
{"n":"C","t":"D","x":"B","z":"A"}