Question Detail

How to convert String to Json Object in android?

6 years ago Views 1706 Visit Post Reply

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


- 6 years ago

Is your string is coming from any server/webservice.

Bili Greed

- 6 years ago

The String is Value of my CheckBoxes.


- 6 years ago

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

eg: {


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.


- 5 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();