- Create JSON Java object
- Add name and value pairs using put method
- Convert it to String type using
toString()
method and send it to the client with content-type as \"text/xml\"
or \"text/plain\"
Example
myString = new JSONObject().put(\"JSON\", \"Hello, World!\").toString();
// myString is {\"JSON\": \"Hello, World\"}