Android ParseObject的类型无效
错误:java.lang.IllegalArgumentException:ParseObject的类型无效:class org.json.JSONObject 我已将“centOS”上的解析服务器以及数据库从parse.com移动到mangoDB。当我从我的android应用程序发出以下请求时,我遇到了上述错误 注意:我正在使用android parse sdk(v1.13.1) 我尝试使用addAllUnique()方法将jsonObject添加为arraylist,因为我必须在parse数据库中将jsonObject存储为“数组”的数据类型 下面我分享我的代码:Android ParseObject的类型无效,android,parse-platform,Android,Parse Platform,错误:java.lang.IllegalArgumentException:ParseObject的类型无效:class org.json.JSONObject 我已将“centOS”上的解析服务器以及数据库从parse.com移动到mangoDB。当我从我的android应用程序发出以下请求时,我遇到了上述错误 注意:我正在使用android parse sdk(v1.13.1) 我尝试使用addAllUnique()方法将jsonObject添加为arraylist,因为我必须在parse数
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("__type", "Pointer");
jsonObj.put("className", className);
jsonObj.put("objectId", objectId);
} catch (JSONException e1) {
e1.printStackTrace();
}
ParseUser user = ParseUser.getCurrentUser();
user.addAllUnique("Keyword",Arrays.asList(jsonObj));
user.saveInBackground();
我还尝试了user.addAll()方法代替addAllUnique(),但它也不起作用
请帮我解决这个问题。谢谢您可以尝试这样的方法,而不是JSON对象
List<ParseObject> pointerList = new ArrayList<>();
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
...
user.addAllUnique("keyWord", pointerList);
user.saveInBackground();
List pointerList=new ArrayList();
add(ParseObject.createWithoutData(“YourClassName”、“yourobjectId”);
add(ParseObject.createWithoutData(“YourClassName”、“yourobjectId”);
...
addAllUnique(“关键字”,指针列表);
user.saveInBackground();
还没有测试代码。但从技术上讲,这应该是可行的
希望这对您有所帮助:)您可以尝试类似的方法,而不是JSON对象
List<ParseObject> pointerList = new ArrayList<>();
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
...
user.addAllUnique("keyWord", pointerList);
user.saveInBackground();
List pointerList=new ArrayList();
add(ParseObject.createWithoutData(“YourClassName”、“yourobjectId”);
add(ParseObject.createWithoutData(“YourClassName”、“yourobjectId”);
...
addAllUnique(“关键字”,指针列表);
user.saveInBackground();
还没有测试代码。但从技术上讲,这应该是可行的
希望这能有所帮助:)发布你的错误日志你可能在这里混合了隐喻。。指针类型的显式使用来自RESTAPI。如果您使用的是android SDK,则只需将类名创建为对象,并将其包装在命名元素中,然后将其添加到您要指向的类中。@RobertRowntree谢谢您的建议,但我必须将jsonObject作为数组数据类型存储在Parse数据库中。在解析之前,迁移代码对我来说很好。请指教,我不清楚你的问题。你想放一个指针数组吗?@YeMinHtut是的,我想存储指针数组。我已经使用addAllUnique()方法在Parse DB中存储了指针数组,在解析迁移之前它工作得很好。。指针类型的显式使用来自RESTAPI。如果您使用的是android SDK,则只需将类名创建为对象,并将其包装在命名元素中,然后将其添加到您要指向的类中。@RobertRowntree谢谢您的建议,但我必须将jsonObject作为数组数据类型存储在Parse数据库中。在解析之前,迁移代码对我来说很好。请指教,我不清楚你的问题。你想放一个指针数组吗?@YeMinHtut是的,我想存储指针数组。我已经使用addAllUnique()方法在Parse DB中存储了指针数组,在解析迁移之前它工作得很好。我感谢您的响应。我尝试过用这段代码将指针数组存储到解析数据库中,但它的存储方式类似于“[[{“objectId”:“Pointer”},{“objectId”:“UserKeyword”},{“objectId”:“6mzDmu8iX1”}]]”,但我需要以下格式。[{uuuu-type:“Pointer”,“className:“UserKeyword”,“objectId:“DkfeM16GtA”},{uuuu-type:“Pointer”,“className:“UserKeyword”,“objectId:“lkcnla8icJ”}]这是因为
数组.asList(pointerList)
。我已经编辑了我的答案。再试一次@在测试之前,请先删除列中的错误数据。我感谢您的回复。我尝试过用这段代码将指针数组存储到解析数据库中,但它的存储方式类似于“[[{“objectId”:“Pointer”},{“objectId”:“UserKeyword”},{“objectId”:“6mzDmu8iX1”}]]”,但我需要以下格式。[{uuuu-type:“Pointer”,“className:“UserKeyword”,“objectId:“DkfeM16GtA”},{uuuu-type:“Pointer”,“className:“UserKeyword”,“objectId:“lkcnla8icJ”}]这是因为数组.asList(pointerList)
。我已经编辑了我的答案。再试一次@在测试列之前,请删除列中的错误数据。