showing results for - "how to convert jsonobject"
Tessa
13 Mar 2020
1import org.json.simple.JSONObject;
2import org.json.simple.parser.JSONParser;
3import org.json.simple.parser.ParseException;
4
5public class TestJSON {
6
7	public static void main(String[] args) {
8
9		JSONObject jObject = new JSONObject();
10
11		jObject.put("EmployeeId", new Integer(121));
12		jObject.put("Name", "Ramesh");
13		jObject.put("Salary", new Double(15000.00));
14		jObject.put("isPermanent", new Boolean(true));
15		jObject.put("Nickname", null);
16		
17		//convert from JSONObject to JSON string
18		String jsonText = jObject.toJSONString();
19
20		System.out.println(jsonText);
21
22		JSONParser parser = new JSONParser();
23		
24		//convert from JSON string to JSONObject
25		JSONObject newJObject = null;
26		try {
27			newJObject = (JSONObject) parser.parse(jsonText);
28		} catch (ParseException e) {
29			e.printStackTrace();
30		}
31
32		System.out.println(newJObject.get("EmployeeId"));
33		System.out.println(newJObject.get("Name"));
34		System.out.println(newJObject.get("Salary"));
35		System.out.println(newJObject.get("isPermanent"));
36		System.out.println(newJObject.get("Nickname"));
37	}
38}
queries leading to this page
convert java object to string jsonobject to json object javachange json value javato object json javahow to covernt josconvert json into java classhow to convert json to string in javaobject to json in javaobject to jsonobject javajava convert object to jsonobjectget object from json string javaconvert jsonobject to java objectjson convert into java stringhow to convert object to jsonobject in javajson to java classstring json to json object javaconvert string into jsonobjectconvert to json object in jaavjava json to objecthow to convert json string to object javahow to convert json object to json string with javaconvert json to string in javahow to convert jsonnode to jsonobject in javaconvert class to jsonjava create json from string objectshow to convert an object to a json string in javahow convert json to object in javajava convert json string to objectconvert string object to jsonobject javaconvert json to class in javahow to convert json 3d in javaobject to json classconvert object in json javaconvert jsonnode to jsonobject in javaconvert json to objconvert object to json string javajava parse json string to jsonobjectconvert jsonobject to modelconveting string object to jsonobjectjson obj to string in javaconverting object in to json objectjava convert jsonobject to objectjsonobject from stringjava convert json to objectconvert json to java objectconvert object to jsonobject javaconvert jsonobject to object javaconvert in bject jsonjson string to json object in javajson obj to string javaconvert obj to json javaconvert to jsonobjectjaav object to json stringconvert object in jsonconvert json to java classhow to convert object data into json in javahow to convert a json string to an object in javaconvert json to class object javaconvert json string to jsonobjectstring to jsonpobject java object to string jsonconverting an object to json in javaclass to json javajson string to jsonobjectjava string to json objecthow to convert json object to object in javaconvert json to object javahow to convert java object to json stringconvert string to jsonpobjecthow do i convert json object in javaconvert string into json on 3dbjectjava convert json into objectshow to convert string json data to object javastringified json to json javaconverting java object to jsonconverting a json object to classconvert objects get to jsonconvert string to jsonobject in javafrom jason convert classjson to class convertstring json to jsonobjectconvert class object to jsonjsonobject to string conversion in javaconvert string to jsonobject javahow to create a json string from an object in javajsonobject to string javaconvert jsonobject to ojectcan you convert a obj to jsonjava object to jsonobject to string json javaconver json to classobject to json string javajsonobject from string javajson to string javaconvert a java object to jsonhow to use json as string in javahow to convert obj to jsonconvert json to object in javajson to string java objectconvert jsonobject to stringstring to jsonobjectjava get convert jsonobject to objectinject json into jsonhow to convert var to jsonobjectstring json to object javajava convert object to jsonhow to convert jsonnode to json in javajson object to json string in javahow to convert java object to jsonhow to convert json string to json object with javahow to convert java object to json objecthow to read data from java object and convert it into a json bjecthow to cast json object to object in javahow to convert object into jsonobject in javajson to string with 5c in javacreate json from strings jsonobjecthow to convert string in jsonobjectjson object to string javaconvert something to json java jcksonjson to class javahow to convert object object to jsoncovertobject to json javajson simple string to jsonobjectcreate object from json stringstring to jsonobject javahow to convert json to objectjsonobject to stringjson object into java objecthow to convert json object to string in javaconvert jsonvalue to jsonobjectconverting object to jsonobjectconvert json object to string javahow to json to string in javaconvet json to string javaconvert class object to json javahow to parse json object to string in javahow to convert java object to json object in javajson to bjectconvert set of entries to jsonobject javajava object to json stringhow to convert string to jsonobjecthow to convert json string to java object using jacksonjava object to json objectconvert object to json javaconvert java object to jsonconvert jsonobject to java classhow to convert json string into java object using objectmapperhow to convert a object with function as a json objectjava object to json string examplehow to convert a object to jsonconvert class object to json string javajson convert from object how to convert json to java objecthow to convert string to jsonobject javaconvert json to string variable for javajson string to json object javajava jsonobject to stringconvert json object into string in javaobject to json javajson to string in javahow to convert an object to jsonjson object to java objectjava convert principal to json stringconvert object to jsonobjectjsonobject string to jsonjava json to objectconvert class object to jsonobject javaclass transformer from json to objectcovert jsonobject to classconverter class java to jsonjackson convert object to json stringconvert to json javaconvert json into classconverting class object to jsonconvert jsonobject to objectjava json string to objectcreate json object from string in javaconvert json as string javastring json to class object javaclass object to json in javaobject json to string javahow to convert jsonobject