7:57 am - Monday September 24, 2018

Example Program using JSONObject

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

                                This program explains about the concept of JSONObject and the output is also given below.

Example Program

import org.json.JSONException;

import org.json.JSONObject;

class Jsonexample

{

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

	{

		JSONObject obj = new JSONObject();

		obj.put("name", "foo");

		obj.put("num", new Integer(100));

		obj.put("balance", new Double(1000.21));

		obj.put("is_vip", new Boolean(true));

		System.out.print(obj);

	}

}

Output

              {“balance”:1000.21,”num”:100,”is_vip”:true,”name”:”foo”}

BACK

 

Filed in: JSON Tutorial

Comments are closed.