-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.

2
  • what exactly do you mean by json string? And what issue(s) do you have with your code? Commented Feb 16, 2017 at 13:07
  • you want to get string of JSONArray or JSONObject ? Commented Feb 16, 2017 at 13:12

4 Answers 4

0

You can used toString function for this.

array.toString()
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

Use this code, may help you.

    JSONObject json = new JSONObject();
    //put your values
    json.toString();

Comments

0

clear your question please JsonObject to String use:

json.toString();

String to JsonObject:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.