title: Stringify JSON from in GWT ArrayList then return to array
body: <p>Currently attempting to stringify a Java ArrayList object in GWT using an interop method to call the native JSON.stringify(ArrayListobj). This results in a perfect JSON representation of the underlying array list contents in the form of an array. This even works for seemingly more complicated Java class objects, but in this instance I'm going to use Strings to demonstrate. First on my creation side: </p>
  
  <pre><code>test = new ArrayList&lt;&gt;();
  test.add("first");
  test.add("second");
  String jsonstr = JSON.stringify(test);
  </code></pre>
  
  <p>Now based on my JsInterop code, I'm returning an Object (or object array as is the case in the following code shown here): </p>
  
  <pre><code>@JsType(isNative=true, namespace=GLOBAL)
  public class JSON {
    public native static String stringify(Object obj);
    public native static Object[] parse(String obj);
  }
  </code></pre>
  
  <p>So far so good, all of this works perfectly, and the results I get are stringified JSON representation of the contents of the ArrayList</p>
  
  <p><strong>"{"array_0":["first","second"]}"</strong></p>
  
  <p>Then run this bit through the parser: </p>
  
  <pre><code>ArrayList&lt;String&gt; returned = new ArrayList&lt;&gt;();
  Object[] var = JSON.parse(jsonstr);
  </code></pre>
  
  <p>And var IS a proper reprsentation (when looking at the web browsers execution paused) of the underlying data from the first ArrayList. The problem is getting the Object[] of the JSON array converted back to the Java ArrayList object. </p>
  
  <p>I have tried using JSNI code to extract the array elements, which actually in the console tray on the web browser works perfectly, but the compliler tries to outsmart me and renames the <strong>array</strong> element so my JSNI code can't touch it. </p>
  
  <p>If my code is as above, and I write JSNI something like: </p>
  
  <pre><code>    public static native ArrayList objToList(ArrayList add,Object inVal) /*-{
           var length = inVal.array.length;
           for(var i = 0;i &lt; length; i++){
               add.array[i] = inVal.array[i];
           }
           return add;
       }-*/;
  </code></pre>
  
  <p>Then the compiler will rename the array <strong>array_0</strong> so my code that says inVal.array no longer ties in with the data I'm trying to access. </p>
  
  <p>From all the testing I've done this is by far the fastest method of getting the same ArrayList object (its guaranteed to be defined the same way in both places) from one place in the client software to another place in client software (no server involved here) through stringification. </p>
  
  <p>But the information about how to manipulate the JavaScript on a low level in GWT is, lacking at best.</p>
  
  <p>And I've tried every variation on GWT-RPC mechanisms, GWT-Jackson, AutoBeans (if only they supported objects with multiple primitive types!) requestbuilder, you name it. </p>
  
  <p>And NO, before you suggest it I'm not interested in doing a full GWT-JSON parse of the string again, I already did that when originally pulling the thousands of records off the server and pushed them into the Java ArrayList. It takes 200+mS to parse the JSON in GWT, while the browsers JSON parse function processes this string in around 3mS. </p>