简体   繁体   中英

Integer array get converted as a string when added as json parameter

I want to add integer array as a request param in json .I am adding it by using the method.

org.json.JSONObject jsonObject=new org.json.JSONObject();
jsonObject.accumulate("",integerArray); 

but when i am adding it as a param it get converted as string,so not able to parse on server side. Android-Client side. Java -Server side.

I'm not a JSON expert, but have you converted it back to a JSONArray on the server side?

JSONArray array = jsonObject.optJSONArray("myArray");

To make this work you have to call sonObject.accumulate("myArray",integerArray); of course.

Use

org.json.JSONObject jsonObject=new org.json.JSONObject();
jsonObject.accumulate("",new org.json.JSONArray(integerArray));

on the client side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM