Venkatesh Selvam Venkatesh Selvam - 1 year ago 102
JSON Question

Android HTTP Post- send Json Parameters without double quotes

I want to send Json Parameters (below) in Android - POST Method.

{"message":"This is venkatesh","visit":[5,1,2]}

I tried the below code

String IDs="5,1,2";
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", "This is venkatesh");

JSONArray jsonArray = new JSONArray();
jsonObject.put("visit", jsonArray);
String json = jsonObject.toString();
Log.d("Mainactivity", " json" + json);

I am getting the output is

{"message":"This is venkatesh","visit":["5,1,2"]}
// Output i am get with double quotes inside visit

{"message":"This is venkatesh","visit":[5,1,2]}
// I want to send this parameter without Double quotes inside the Visit

Answer Source
String IDs="5,1,2";
String[] numbers = IDs.split(",");
                JSONArray jsonArray = new JSONArray();
for(int i = 0; i < numbers.length(); i++)

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download