Friday, August 19, 2016

Re: Best Practice for JSON object recreation on client

This makes sense for newer projects maybe.

I already have a codebase and making trampolines to convert collections and maps to arrays and don't know what is a terrifying option.

I prefer to depend on gwt-jackson (which doesn't work for me - resty-gwt works - resty-gwt is switching to gwt-jackson - eventually gwt-jackson will work for me) especially if I am using jackson already in the server,


On Fri, Aug 19, 2016 at 5:02 PM, Ignacio Baca Moreno-Torres <ignacio@bacamt.com> wrote:
IMHO supporting the whole collection frameworks is just an unnecessary complication. Just use plain array, not generics need, and now that stream are supported in GWT you has no excuse to use arrays. The inheritance is not solved in JsInterop for now, just try to avoid.

On Friday, August 19, 2016 at 3:38:28 PM UTC+2, Vassilis Virvilis wrote:
How about transmitting nested Collections, Map, complex inheritance and generics?

On Fri, Aug 19, 2016 at 4:30 PM, zakaria amine <zakaria...@gmail.com> wrote:
I also tried to convert back to the original object: 

@JsType(isNative=true, namespace=GLOBAL)
public class JSON {
public native static String stringify(Object obj);
public native static Object parse(String obj);

}

and then: 
//....

  Record converted = (Record) JSON.parse(json);

and it works just fine. why would we need something like gwt-jackson anymore? 


Le vendredi 19 août 2016 12:05:32 UTC+2, zakaria amine a écrit :
It works. I prefer your solution.

Le vendredi 19 août 2016 11:51:35 UTC+2, Jens a écrit :


Am Freitag, 19. August 2016 11:43:12 UTC+2 schrieb zakaria amine:
I have tried something like: 

@JsType(namespace=GLOBAL)
public class Record {
String id;
String date;
String data;
public Record() {
}
}

By default @JsType property "isNative" is false, so your Record class is a non-native class that might get exported to JS if you use -generateJsInteropExports during compilation. If you don't use that flag the @JsType is treated as a normal class I guess.

You should use @JsType(isNative=true, namespace=GLOBAL, name="Object") so that your Record class becomes a plain JavaScript object

-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.



--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.



--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment