The reason why you are getting \
in your print line is because it is escaping the "
character which is used in value
. There's nothing wrong with this, it simply signifies that \"
is not terminating the string and is instead a value part of that string.
Usage of double quotations is valid JSON, not single quotes - see related Q here.
But if you really want to, if you create value
like this:
JSONObject value = new JSONObject("{'min':10,'max':40}");
Then you should get the desired output from your existing code:
1:{"min":10,"max":40}
2:{"TEST":{"min":10,"max":40}}