Android JSONObject and JSONArray allows you to save your custom class values on the Parse.com as a json string.
Suppose you would like to save your custom class values in a single Parse.com class column, you can just convert your class parameter values in JSONObject and then can save in a column on Parse.com.
Saving JSONObject on Parse
Saving JSONArray on Parse [ If you like to save an array of custom class instances]
Suppose you would like to save your custom class values in a single Parse.com class column, you can just convert your class parameter values in JSONObject and then can save in a column on Parse.com.
Saving JSONObject on Parse
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");
// Add your JSONObject
parseObject.put("myCustomClass",new JSONObject().put("key","value"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject
// Save the Parse object
parseObject.saveInBackground();
Saving JSONArray on Parse [ If you like to save an array of custom class instances]
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");
// Add your JSONArray
JSONArray jsonArray = new JSONArray("myCustomClassArray");
jsonArray.put(new JSONObject().put("key1","value1"));
jsonArray.put(new JSONObject().put("key2","value2"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject
// Save the Parse object
parseObject.saveInBackground();
No comments:
Post a Comment