我有一个 JSON 对象,它转换为字符串并保存到数据库中。但是当我试图取回它时,它抛出异常。我的对象是这样的......
{"COLUMN":["Type","Sub Type","F.P.","P.P.","Process","Due To Start"]}
我们如何才能以正常形式获取数据?
我的Java代码是......
JSONObject obj = new JSONObject();
JSONArray the_json_array = obj.getJSONArray(userReorderOption);
int size = the_json_array.size();
ArrayList<JSONObject> arrays = new ArrayList<JSONObject>();
for (int i = 0; i < size; i++) {
JSONObject another_json_object = the_json_array.getJSONObject(i);
arrays.add(another_json_object);
}
我得到了例外....
net.sf.json.JSONException: JSONObject["{\"TASKLIST_COLUMN_REORDER\":[\"Type\",\"Sub Type\",\"F.P.\",\"P.P.\",\"Process\",\"Due To Start\"]}"] is not a JSONArray.
这是java代码我如何创建JSON对象并保存到数据库中......
String userReorderSelection;
Set set = new LinkedHashSet(userReorderSelection);
JSONObject json = new JSONObject();
json.accumulate("COLUMN", set);
saveJSONObj("PrimaryKeyColumn", json.toString());