top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Generate or Send JSON Data at the Server Side?

0 votes
313 views
How to Generate or Send JSON Data at the Server Side?
posted Jul 14, 2017 by Arun Angadi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
  • 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\"}
answer Jul 14, 2017 by Biswajit Maity
...