I want to make JSON object from database but there is one complex structure. I am not clear that how to make complex structure like "values" in following Json string.Help anybody,thanks in advance.This is the Json string which i want to make:
[{"type":"person1","id":null,"values":[[[32.3619,50.9291],[32.3604,50.9644],[32.3446,50.9395]]]}]
code I have tried yet.
Session sess1 = sf.openSession();
Query q = sess1.createQuery("from person");
List l = q.list();
Iterator itr = l.iterator();
JSONArray jArray = new JSONArray();
JSONObject jObj = new JSONObject();
String id = null, lat, lng;
while (itr.hasNext()) {
Person pobj = (Person) itr.next();
id = pobj.getId().toString();
lat = pobj.getLatitude();
lng = pobj.getLongitude();
}
jObj.put("type", "Person1");
jObj.put("id", id);
JSONArray jrray = new JSONArray();
jArray.put(jObj);
JSONObject jObjDevice = new JSONObject();
jObjDevice.put("", jArray);
System.out.println("json object created" + jObjDevice.toString());