![](/img/trans.png)
[英]How to send Integer value in the form of JSON format and recieve in REST Controller?
[英]Unable to send Integer value to server using json
我正在尝试将以下Integer值发送到服务器。
int mStoreArea;
我将此链接用作REST客户端。 这是请求:
RestClient client = new RestClient(my_url);
client.AddParam("area", String.valueOf(c.getStoreArea()));
我遇到的错误是: Int value required!
我从保存到文件的json对象中检索此整数,其过程如下所述:
public myClass(JSONObject json) throws JSONException {
mStoreArea = json.optInt(JSON_TAG);
}
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put(JSON_TAG, mStoreArea);
return json;
}
我认为您应该使用此:
client.AddParam("area", Integer.parseInt(c.getStoreArea()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.