In the project, I have to send complex JSON commands from the server to the client. Is it efficient to generate JSONObjects (strings, numbers, etc.) Convert them to a string and then send them via RequestBuilder or is there a more efficient method.
Is it efficient to convert JSON objects to string (via the object's .toString method)
Code example:
JSONObject retObject = new JSONObject(); retObject.put("NumberVar", new JSONNumber(1)); retObject.put("StringVar", new JSONString("HelloWorld")); JSONArray arrayVar= new JSONArray(); for (int i = 0; i < 5; i++) { arrayVar.set(i, new JSONString("Array")); } retObject.put("EventParameters", arrayVar); System.out.println(retObject.toString());
Exit:
{"NumberVar":1, "StringVar":"HelloWorld", "EventParameters":["Array","Array","Array","Array","Array"]}
Regards, Stefan
json gwt
Stefan
source share