JSONArray of JSONObject in Java

0 votes


I'm trying to get an array or JSONObject like this :

JSONArray array = new JSONArray();
JSONObject jsonResponse = new JSONObject();
jsonResponse.put("Login", players.get(i).Login);

return new HttpResponseObject(HTTP_STATUS_SUCCESS,

Here's what I get : 
Success : {"{\"Login\":\"3dduck\",\"Wifes\":1,\"Diamonds\":21,\"MoneyBuilding\":435}":{"Login":"3dduck", "Wifes":"1", "Diamonds":"21", "MoneyBuilding":"435"}, "{\"Login\":\"gamecat\",\"Wifes\":2,\"Diamonds\":0,\"MoneyBuilding\":166}":{"Login":"gamecat", "Wifes":"2", "Diamonds":"0", "MoneyBuilding":"166"}, "{\"Login\":\"Mechant Raton\",\"Wifes\":20,\"Diamonds\":550,\"MoneyBuilding\":1420}":{"Login":"Mechant Raton", "Wifes":"20", "Diamonds":"550", "MoneyBuilding":"1420"}}

I get everything in double, what did I wrong ?

Thank you, your support is amazing !


asked Jul 1, 2014 in App42 Cloud API-BaaS by moddib (27 points)

1 Answer

0 votes
Best answer

From the JAVA documentation :

toJSONObject :
Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
names - A JSONArray containing a list of key strings. These will be paired with the values.


So only an array of names was needed.

answered Jul 2, 2014 by moddib (27 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com