I have a JSONObject
{"notes":{
"remarks":["abc","xyz"],
"factory notes":["abc","xyz"],
"name":"jdfb"
}
}
** i want to insert it to a table as remarks as a string factory notes as a string and name is already a string. but when i iterate this how do i know if it is array or string. whats the condition for that?
for name i could do obj.getString("name"), and for array its getJsonarray. if i can distinguish that i could easily convert it to string and inset to the table.**
String description=null;
Iterator<String> notesIterator = notesObj.keys();
while (notesIterator.hasNext()) {
String notesKey = notesIterator.next();
Object notesItrObj=notesIterator.next();
if(notesItrObj instanceof String ) {
description=notesObj.getString(notesKey);
}
else {
JSONArray
notesArray=notesObj.getJSONArray(notesKey);
description=notesArray.toString();
}