Reputation: 23
Error : java.lang.IllegalArgumentException: invalid type for ParseObject: class org.json.JSONObject
I have moved parse server on "centOS" and also database from parse.com to mangoDB. I'm getting Above error when I make below request from my android app.
Note : I'm using android parse sdk(v1.13.1)
I have tried to add jsonObject as arraylist using addAllUnique() method because I have to store jsonObject as datatype of "array" in parse database.
Below i share my code :
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();
I have also tried user.addAll() method insted of addAllUnique() but it's also not working.
Please help me to resolve this. Thanks
Upvotes: 0
Views: 934
Reputation: 2904
You can try something like this instead of JSON Object.
List<ParseObject> pointerList = new ArrayList<>();
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
pointerList.add(ParseObject.createWithoutData("YourClassName", "yourobjectId"));
...
user.addAllUnique("keyWord", pointerList);
user.saveInBackground();
Haven't tested the code yet. But technically, it should work.
Hope this helps :)
Upvotes: 4