Creating JSON data in Java

This post is about how to create JSON data in java. The following code snippet is

public static void main(String args[]) throws JSONException {

JSONObject json = new JSONObject();
 json.put("city", "chennai");
 json.put("country", "india");

String output = json.toString();
 System.out.println(output);

}

Jar File: https://mvnrepository.com/artifact/org.json/json/20090211.

Hope this helps. Please subscribe and comment if you have doubts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s