The following code
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayMixed;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONString;
[...]
JsArrayMixed jsArray = JavaScriptObject.createArray().cast();
jsArray.push("something");
JSONArray jsonArray = new JSONArray(jsArray);
System.out.println(jsonArray.size());
will print "0" instead of the expected "1" when run with gwt-test-utils. Looking at the JSONArrayPatcher in gwt-test-utils it seems that the value given to the constructor is completely ignored.
Is there a way to make those lines print "1"? Maybe there is a way to patch the constructor of JSONArray?
JSONArrayhas nothing to do withJsArrayMixed.JSONArrayisorg.json.JSONArrayandJsArrayMixedis gwt client object of typecom.google.gwt.core.client.JsArrayMixed. These are so completedly from different class hierarchy, that they don't just understand each other.JSONArraymaybe works if you construct it withJSONObjectinstance or anotherJSONArray.You have to invent another way to construct your mixed object.
My sources:
[1] http://www.json.org/javadoc/org/json/JSONArray.html
[2] http://srcrr.com/java/google/gwt/2.2/reference/com/google/gwt/core/client/JsArrayMixed.html