Question Detail

I have multiple checkboxes I want to save their Values in the database but I don't want to create different columns for the checkbox. So I want to their value in JSON and then save JSON in the database but I am not able to convert String or Array to JsonObject?


Image result for multiple checkbox android


Thread Reply

Anonymous

- 1 years ago

Is your string is coming from any server/webservice.

Bili Greed

- 1 years ago

Nope,
The String is Value of my CheckBoxes.

Anonymous

- 1 years ago

Jeon is just a string in a given format. All u need is a key and a value.

eg: {

"name":"raj"}

All u need is a key (name) and a value (raj).

put your data in the value and give it a key name and than u can parse your data however you want.

Anonymous

- 1 years ago

this is the way how you can convert string Variables to Json 

JSONObject jsonBody = new JSONObject();
jsonBody.put("Title", "Android");
jsonBody.put("des", "Development");
final String requestBody = jsonBody.toString();