[英]ParseObject getString() returns null for Pointer column
I have something like this 我有这样的东西
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("MyTable");
query.include("tag");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objectList, ParseException e) {
if (e == null) {
for(ParseObject objects : objectList) {
Log.d(TAG, "parse object name : " + objects.getString("name"));
Log.d(TAG, "tag name : " + objects.getString("tag"));
}
}
}
}
for each row, I have columns like String name
and Pointer<Tag>
. 对于每一行,我都有诸如
String name
和Pointer<Tag>
。
In LogCat, it prints out names correctly, but it prints out null
for each tag. 在LogCat中,它可以正确打印出名称,但为每个标签打印出
null
。
parse object name : Events
tag name : null
I don't actually need to get pointer, but all I need is to get the tag in String format (I can't modify the table to make the column String now). 我实际上不需要获取指针,但是我所需要的只是获取String格式的标记(我现在不能修改表以使String列)。
What can I do to be able to get the Pointer as String format? 我该怎么办才能获得Pointer as String格式?
Use this to get value from pointer. 使用它从指针获取值。
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("MyTable");
query.include("tag");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> objectList, ParseException e) {
if (e == null) {
for(ParseObject objects : objectList) {
Log.d(TAG, "parse object name : " + objects.getString("name"));
ParseObject tagObject=objects.getParseObject("tag");
//Now access your tag class column
Log.d(TAG, "tag name : " + tagObject.getString("columnName"));
}
}
}
}
Try on this line code for log
尝试使用此行代码进行
log
Log.e(TAG, "tag name : " + objects.getParseObject("tag").getString("col_name");
this way to fetch parse pointer object
. 这种方式来获取
parse pointer object
。
To read value of a pointer,read it as a parse object. 要读取指针的值,请将其作为解析对象读取。
Log.d(TAG, "tag name : " + objects.getParseObject("tag"));
Note : When you are doing your query you must to include the pointer field if you want to be able to extract the data from it after the query will be returned. 注意 :执行查询时,如果希望在返回查询后能够从中提取数据,则必须包括指针字段。 The result:
结果:
query.include("pointer_filed");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.