-1
    JSONArray array = new JSONArray();
    try
    {
        for (int i = 0; i < contactList.size(); i++){

            JSONObject obj = new JSONObject();
            String myString = contactList.get(i);
            Log.e("Contact List",contactList.get(i));
            String[] myarray = myString.split(",");
            obj.put("is_private","0");
            obj.put("expire_date","0000-00-00");
            obj.put("name",myarray[0]);
            obj.put("phone_no",myarray[1]);
            obj.put("user_id", 1);

            array.put(obj);
        }

how we can convert json string to normal string ? please give me answer.

4 Answers4

0

You can used toString function for this.

array.toString()
Rahul Giradkar
  • 1,818
  • 1
  • 17
  • 28
0

JSONObject obj = new JSONObject(yourstring); String x = obj.getString("x");

Jaspinder
  • 1
  • 2
0

Use this code, may help you.

    JSONObject json = new JSONObject();
    //put your values
    json.toString();
Vinit Solanki
  • 1,863
  • 2
  • 15
  • 29
0

clear your question please JsonObject to String use:

json.toString();

String to JsonObject:

String data= "Json format data";
JsonObject obj=new JsonObject(data);