Java - Parse - iterate over ParseObject fields

前端 未结 1 1923
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-24 10:07

Having a ParseObject object how can I loop through its fields and get the name of the field along with the value of it? This would really help me minimize my code.

相关标签:
1条回答
  • Hmm, ParseObject contains key-value pairs, and I think you can't iterate though it. But. I found something called .keySet() method of ParseObject. It returns ... well, the set of keys (excluding createdAt, updatedAt, authData, or objectId). I think you can convert it into an array and iterate trhough it?

    Something like this:

    Set<String> keySet = parseObject.keySet();
    String[] parseKeys = keySet.toArray(new String[keySet.size()]);
    for (String key : parseKeys) {
        String parseValue = parseObject.get(key);        
        //do whatever you want
     }
    
    0 讨论(0)
提交回复
热议问题