user3122468
user3122468

Reputation: 39

How pass values into web service using JSON

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

Answers (1)

Rishabh Srivastava
Rishabh Srivastava

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

Related Questions