Yes, theoretically you should be able to use the second parameter on
Json.parse Json.stringify for conversion back and forth between java
collections and js primitives. In this model, your javascript code needs to
use Java collection APIs.

> java.util.Arrays.asList() should be enough

keep in mind that Arrays.asList won't let you go out of bounds.


> I believe it was in plans with @JsConvert


We are not working on @JsConvert right now. JsConvert is just convenience
and you can mimic it:


  @JsType(isNative=true)
  interface MyType {
     @JsConvert(ListConverter.class)
     List getMyArray()
     void setMyArray(@JsConvert(ListConverter.class) List array)
  }

is roughly equivalent to:

  @JsType(isNative=true)
  interface MyType {
     @JsProperty(name="myArray")
     Object[] getMyArrayInternal();

     @JsOverlay
     default List getMyArray() { return Arrays.asList(getMyArray()); }

     @JsProperty(name="myArray")
     void setMyArrayInternal(Object[] array);

     @JsOverlay
     default void setMyArray(List list) {
       setMyArrayInternal(array.toArray());
     }
  }


On Tue, May 9, 2017 at 9:32 AM, Thomas Broyer <t.bro...@gmail.com> wrote:

>
>
> On Tuesday, May 9, 2017 at 4:34:48 PM UTC+2, Marcin Okraszewski wrote:
>>
>> There is indeed something in it. Actually you could have some type of
>> naming convention, like in TJSON (https://tonyarcieri.com/intro
>> ducing-tjson-a-stricter-typed-form-of-json) or TypedJson (
>> https://www.npmjs.com/package/typed-json) to figure out proper types.
>> But then I would need to create eg. ArrayList with the Manuel's trick (the
>> asList() from Polymer). I'll test it.
>>
>
> java.util.Arrays.asList() should be enough actually: https://github.com/
> gwtproject/gwt/blob/2.8.1/user/super/com/google/gwt/
> emul/java/util/Arrays.java#L136 (note that the ArrayList there is not
> java.util.ArrayList, it's an internal java.util.Arrays.ArrayList class that
> directly wraps the array with no copy).
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-web-toolkit-contributors/95e1bd43-b4a6-
> 4b2d-bd89-6cc6fb206631%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/95e1bd43-b4a6-4b2d-bd89-6cc6fb206631%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0Wr0pWKUcqyN2YMkuoZZK7b3e-ipm7jqv2DdDeqk8sMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to