0

I have to send this Json:

{"method":"startSession", "params":["email" "email@email.it", "password" "1234", "stayLogged" "1", "idClient" "IPHONE"], "id":1} 

the problem is that: I don't know how to send a json with Exactly this form because of the params' value array, I must send the array as value of the key params, but if I try to use:

jsonObject.put("params", paramemsArr);

to put a String array, the put doesn't work correctly and the Json assume a wrong form

If I try to put the params in a Json array and add the json array in analogue way the json assume the wrong form

{"method":"startSession", "params":[{"email" "email@email.it", "password" "1234", "stayLogged" "1", "idClient" "IPHONE"}], "id":1} 

How could I send a Json with exactly this form

{"method":"startSession", "params":["", "email@email.it", "password", "stayLogged", "idClient"], "id":1}
AndreaF
  • 11,975
  • 27
  • 102
  • 168

1 Answers1

0

define paramemsArr as JSONArray instead of a String array, read more about JSONArray at http://developer.android.com/reference/org/json/JSONArray.html

Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131
  • I have tried to sent Json array but get a 500 error from server... my output json sent on println is {"id":1,"method":"startSession","params":["","email@email.it","password","stayLogged","idClient"]} that seems the same accepted by server, but dosn't work – AndreaF Mar 05 '12 at 02:31
  • did you get the output you want with using JSONArray ? maybe the problem is with the server – Gal Ben-Haim Mar 05 '12 at 07:00
  • yes but the server doesn't recognize it as a json rpc call, with ios the same json is accepted and works fine – AndreaF Mar 05 '12 at 10:51
  • you understand that if it works with the same JSON with ios the problem is elsewhere ? anyway, with JSONObject abd JSONArray you build a valid JSON string, please mark the answer as accepted – Gal Ben-Haim Mar 05 '12 at 11:10