且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Android中使用REST API从Firebase数据库检索数据?

更新时间:2022-04-02 00:36:57

如果仅由于键而在解析时遇到问题,则可以使用迭代器提取键并对其进行解析

If you are having problem in parsing just because of keys then you can use a iterator and extract the keys and parse them

if(jObj != null){
    Iterator<Object> keys = jObj.keys();
    while(keys.hasNext()){
        String key = String.valueOf(keys.next()); // this will be your JsonObject key
        JSONObject childObj = jObj.getJSONObject(key);
        if(childObj != null){
             //Parse the data inside your JSONObject
        }
    }
}