0

完成一个活动的执行后,我想让 jSONArray 为空或删除它。因为当我重复调用活动时,新数据会附加到 JSONArray 中存在的旧数据。我的 jsonArray 如下图所示..

[{"record":[
            {......},
            {.......}
           ]
 },
 {"record":[
            {..........},
            {.........}
           ]
 }
] 


First time:
[{"record":[{"intensity":"Low","Body_SubParts":"Scalp","symptom":"Bleeding"}]}]

Second time:
[{"record":[{"intensity":"Low","Body_SubParts":"Scalp","symptom":"Bleeding"},
{"intensity":"Low","Body_SubParts":"Eyes","symptom":"Bleeding"}]}]
4

2 回答 2

0

在这里回答

// Assuming you have constructed the replacement as
JSONObject jsonArray11_obj2 = new JSONObject();
jsonArray11_obj2.put("intensity", "high");
jsonArray11_obj2.put("Body_SubParts", "Scalp");
// ...

// Then the code doing the replacement would look similar to
int index = 0;
((JSONObject)jsonArray.get(index)).getJSONArray("record").put(0, jsonArray11_obj2);
于 2012-04-09T09:05:03.987 回答
0

构建JSON数组后,使对象无效JSONArray..下次再次构建JSON数组

于 2012-04-09T09:15:27.053 回答