我在 Android 应用程序中使用 Parse.com 服务,但当我尝试从 Parse 获取数据时,出现错误:
com.parse.ParseException: corrupted json: org.json.JSONException: No value for code
这是我用来获取数据的代码:
public void getCategories() {
listCategories = new ArrayList<>();
ParseQuery<Category> query = ParseQuery.getQuery(Category.class);
query.findInBackground(new FindCallback<Category>() {
@Override
public void done(List<Category> categories, ParseException e) {
if (e == null) {
// Clear previously loaded Categories
listCategories.clear();
for (Category category : categories) {
// Fill the list with retrieved Categories
lsistCategories.add(category);
}
}else {
Log.d("Error happened while retrieving data:", e.getMessage());
}
}
});
}
知道可能是什么问题吗?
最佳答案
我解决了这个问题,事实上我忘记在我的应用程序类中注册我的自定义类别类。
我将其添加到我的 Application 类的 onCreate 方法中,现在它可以工作了:
ParseObject.registerSubclass(Category.class);
关于java - Android Parse.com 返回损坏的 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27523607/