我正在使用 JSON-simple 库来解析 Json 格式。如何将某些内容附加到 JSONArray?例如,考虑以下 json
{
"a": "b"
"features": [{/*some complex object*/}, {/*some complex object*/}]
}
我需要在features
. 我正在尝试创建这样的函数:-
public void appendToList(JSONObject jsonObj, JSONObject toBeAppended){
JSONArray arr = (JSONArray)jsonObj.get("features");
//1) append the new feature
//2) update the jsonObj
}
如何实现上述代码中的第 1 步和第 2 步?