My code to create a new JSONObject and write to a file:
JSONObject obj = new JSONObject(); obj.put(\"name\", \"abcd\"); obj.put(\"age\", new Integer(100)); J
I meet the same question, if you want to use toJSONString() you need to import json-simple-1.1.jar library.
toJSONString()
json-simple-1.1.jar