繁体   English   中英

添加为json参数时,整数数组将转换为字符串

[英]Integer array get converted as a string when added as json parameter

我想在json中添加整数数组作为请求参数。我正在使用方法添加它。

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

但是当我将其添加为参数时,它会转换为字符串,因此无法在服务器端进行解析。 Android客户端。 Java-服务器端。

我不是JSON专家,但是您将其转换回服务器端的JSONArray了吗?

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

为此,您必须调用sonObject.accumulate("myArray",integerArray); 当然。

采用

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

在客户端。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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