如何将JSONArray从Android客户端发送到服务器? getJsonArray()是一个返回 JsonArray 的函数,但是当我向服务器发送数组时,它看起来像这样:
{
"IMEI": "xxxxxxxxxxxxxxx",
"Puls": ["101", "125", "103", "81"],
"Pasi": ["0", "0", "0", "0"],
"Latitudine": ["0", "0", "0", "0"],
"Longitudine": ["0IMEI=xxxxxxxxxxxxxxx", "0IMEI=xxxxxxxxxxxxxxx", "0IMEI=xxxxxxxxxxxxxxx", "0"]
}
我不知道为什么第一个IMEI在正确的地方而其他人不在......
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
for (int i = 0; i < getJsonArray().length(); i++) {
writer.write(getPostDataString(getJsonArray().getJSONObject(i)));
}
答案 0 :(得分:0)
主数组中的数组应如下所示: -
"Puls": [
{
"number" : "101"
},
{
"number" : "125"
},
{
"number" : "103"
},
{
"number" : "81"
},
]
尝试像这样格式化数组...
答案 1 :(得分:0)
String strloadMainCategory =&#34; api&#34; + URLEncoder.encode(&#34;&#34;,&#34; UTF-8&#34;);
RestClient restClient = new RestClient(strloadMainCategory);
试试{enter code here
restClient.Execute(RequestMethod.GET);
} catch(例外e){}