我是android的新手。当前我在网络服务工作。但这次我遇到了一个问题。我想用json将值传递到服务器.JSOn数组就是这种形式。
{"request":{"api_key":"valid api key", "action":"register", "firstName":"aromal", "lastName":"chekavar", "email":"aromal@mstcochin.com", "address":"test address", "city":"test city", "state":"test state", "dob":"2008-06-26", "gender":"Male", "zipCode":"123456", "pin":"1234", "deviceId":"valid device id", "gcmRegId":"111111","country":"5"
}}
请帮帮我..
答案 0 :(得分:1)
JSONObject request = new JSONObject();
JSONObject jobj = new JSONObject();
jobj.put("api_key", valiapikey);
jobj.put("action", register);
...............................
request.put("request", jobj);
创建一个JSON对象(这里是jobj),用它们的键包含所有参数,然后将它包含在“request”JSON对象中。