Woton Sampaio
Woton Sampaio

Reputation: 456

Json full of "\"

I'm putting a json inside another like this:

JSONObject json = new JSONObject();

for(.....){
  JSONObject v = new JSONObject();

  v.put("key", "value");
  v.put("key", "value");
  v.put("key", "value");

  json.put(i, v.toString());

  i++;  
}

The problem is that it is getting like this:

{"0":"{\"key\":\"value\",\"key\":\"value\",...}"}

Filled with "\", does anyone know how to withdraw or do the "right mode"?

Upvotes: 2

Views: 136

Answers (1)

GolamMazid Sajib
GolamMazid Sajib

Reputation: 9437

cause you put string in json. change this:

from:

json.put(i, v.toString());

to:

json.put(i, v);

Upvotes: 5

Related Questions