develog

[json] JSONObject 본문

카테고리 없음

[json] JSONObject

냐옴 2019. 9. 17. 19:23
String str1 = "{\"list\":[{\"col1\":\"11\",\"col2\":\"12\"},{\"col1\":\"21\",\"col2\":\"22\"}]}";
String str2 = "[{\"col1\":\"11\",\"col2\":\"12\"},{\"col1\":\"21\",\"col2\":\"22\"}]";

Map map = JSONObject.fromObject(str1);
System.out.println();
System.out.println("map : " + map);
System.out.println("map.get(list) : " + map.get("list"));

List list = JSONArray.fromObject(str2);
System.out.println();
System.out.println("list : " + list);
System.out.println("list.size() : " + list.size());
Comments