Reputation: 2535
I am preparing a json object to be sent over a webservice , I am trying to put a list of String in the object, Something like this:
["24348f08-92f4-481a-9a36-ed0d533ca4f3", "24348f08-92f4-481a-9a36-ed0d533ca4f3"]
What i have done:
sendData.put("SpecializationAlert",Specialization);
sendData is a json object and Specialization is a String array, the result when i log this is:
"[\"24348f08-92f4-481a-9a36-ed0d533ca4f3\",\"24348f08-92f4-481a-9a36-ed0d533ca4f3\"]"
Upvotes: 3
Views: 1492
Reputation: 16790
Specialization
is put in the JSON as a toString()
-ed object. You may create a JSONArray from it first and then include it in the JSONObject:
sendData.put("SpecializationAlert",new JSONArray(Arrays.asList(Specialization)));
Upvotes: 2