本文介绍了Java-解析-遍历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-解析-遍历ParseObject字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 10:02