Reputation: 39
I am new in android.Currently i am working in web service.But this time i got one problem.I want to pass values into server using json.The JSOn array is in this form.
{"request":{"api_key":"valid api key", "action":"register", "firstName":"aromal", "lastName":"chekavar", "email":"[email protected]", "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"
}}
Please help me..
Upvotes: 0
Views: 89
Reputation: 3745
JSONObject request = new JSONObject();
JSONObject jobj = new JSONObject();
jobj.put("api_key", valiapikey);
jobj.put("action", register);
...............................
request.put("request", jobj);
Create a JSON object(jobj here) enclosing all your parameters with their keys and then enclose it in "request" JSON object.
Upvotes: 1