Just starting so any facilitation appreciated.
Have an object serialized it to this starting segment:
[{“boo00″:true,”lineItem”:[{“bool00″:true,”display”:false,”extra00″:”objectType”,”status”:””,”value”:”recordType:A”},
{“bool00″:true,”display”:false,”extra00″:”0″,”status”:””,”value”:”UPC:1″},{…},{…}],”rowId”:0,”str00″:”hidden”},
The object has four elements: boo00 (boolean), lineIem (ArrayList), rowID (int), str00 (String)
I have this segment where I am trying to understand how to build back my object
String flatten = lines.toString();
JSONObject outer = JSONObject.fromObject(flatten);
Iterator itr04 = null;
for(itr04 = outer.entrySet().iterator(); itr04.hasNext();){
Map.Entry entry = (Map.Entry) itr04.next();
String key = (String)entry.getKey();
System.out.println("key= "+key);
}
I am getting the following exception:
“net.sf.json.JSONException: A JSONObject text must begin with ‘{‘ at character 1 of []”
which at this point makes little sense to me because that is exactly how it starts.
Your JSON text begins with a square bracket:
[, not a curly brace:{. The JSON string represents an array of objects.Your
outershould be aJSONArray.