本文介绍了Java - Parse - 遍历 ParseObject 字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个 ParseObject 对象,我如何遍历它的字段并获取字段的名称及其值?这真的可以帮助我最大限度地减少代码.

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.

推荐答案

嗯,ParseObject 包含键值对,我认为你不能迭代它.但.我找到了 ParseObject 的一种叫做 .keySet() 的方法.它返回……嗯,键集(不包括 createdAt、updatedAt、authData 或 objectId).我认为您可以将其转换为数组并通过它进行迭代?

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?

像这样:

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
 }

这篇关于Java - Parse - 遍历 ParseObject 字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 03:21