Finding deeply nested key/value in JSON

前端 未结 2 1822
猫巷女王i
猫巷女王i 2021-01-06 22:48

Suppose I have a JSON array like this:

[
    {
        \"id\": \"429d30a1-9364-4d9a-92e0-a17e00b3afba\",
        \"children\": [],
        \"parentid\": \"\"         


        
2条回答
  •  时光取名叫无心
    2021-01-06 23:00

    Based on Stefan Jansen's answer I made some changes and this is what I have now:

    nestedChildren declared globaly, and before the children are searched reset to new ArrayList()

    private void findAllChild(JSONArray array) throws JSONException {
    
        for ( int i=0;i 0 ) {
                findAllChild(json_array);
            }
        }
    }
    

    This assumes it is all Arrays, witch in my case it is

提交回复
热议问题