Re: JSInterop and "JSON.stringify" method return "Converting circular structure to JSON"

2024-05-22 Thread Craig Mitchell
Would it not be easier to just create your JSON object manually with the 
classes in com.google.gwt.json.client?  Ie: JSONObject, JSONArray, ...

On Thursday 23 May 2024 at 1:42:29 am UTC+10 Thomas Broyer wrote:

> On Wednesday, May 22, 2024 at 12:43:56 PM UTC+2 tenti...@gmail.com wrote:
>
> I misunderstood the documentation... ty for the clarification Thomas can 
> you give me some confirmations.
>
> The Date issue, When you say to use the JsDate do you mean the one in the 
> elemental2 package (elemental2.core.JsDate) or in the gwt core (
> com.google.gwt.core.client.JsDate) ?
>
> Any one of them, anything that directly maps to a native JS Date object.
>  
>
> So for the Date issue i just enough to replace this code :
>
> @JsProperty *public* *native* *Date* getDataRepertorioDocumento();
>
>  
>
> @JsProperty *public* *native* *void* setDataRepertorioDocumento(*Date* 
> dataRepertorioDocumento);
>
>  
>
> With:
>
> @JsProperty *public* *native* Js*Date* getDataRepertorioDocumento();
>
>  
>
> @JsProperty *public* *native* *void* setDataRepertorioDocumento(*JsDate* 
> dataRepertorioDocumento);
>
>  
>
> Right ?
>
> Yes.
> (note that it works for serializing because a JS Date object has a 
> toJSON() method that returns its toISOString(), but it won't work for 
> parsing JSON, for that you will have to pass a *reviver* function to 
> JSON.parse() that will have to be aware of your object structure to know 
> that the dataRepertorioDocumento property value needs to be parsed to a 
> Date object, or use a @JsOverlay getter/setter pair that will 
> serialize/parse the java.util.Date or JsDate value to/from the JSON 
> representation you want, same as List and Map)
>
> I also missed an instance of Integer in your objects, this will have to be 
> changed to Double.
>  
>
> For the "List" and "Map" problem, i will probably try to use some 
> @JsOverlay instead to use a second argument  on the JSON.stringify by the 
> way can you point me out some example (i'm not very skilled with this 
> library) ?
>
>
> Could be as simple as (note that a copy is made each time the getter or 
> setter is called):
> ReferenzaDTOGWT[] nodeIdAllegatti;
> // This could also use Elemental's JsArrayLike.asList()
> @JsOverlay public List getNodeIdAllegatti() { return 
> List.of(this.nodeIdAllegatti); }
> @JsOverlay public void setNodeIdAllegatti(List 
> nodeIdAllegatti) { this.nodeIdAllegatti = nodeIdAllegatti.toArray(new 
> ReferenzaDTOGWT[nodeAllegatti.size()]); }
>
> JsPropertyMap errors;
> @JsOverlay public Map getErrors() {
>   var ret = new HashMap();
>   errors.forEach(key -> ret.put(ret, errors.get(key)));
>   return ret;
> }
> @JsOverlay public setErrors(Map errors) {
>   var obj = JsPropertyMap.of();
>   errors.forEach((key, value) -> obj.set(key, value));
>   this.errors = obj;
> }
>
> Of course for the Map> mappaAltriMetadati 
> you'd have to also transform each List.
>
> The JSON.stringify replacer could look like:
> JSONType.StringifyReplacerFn replacer = (key, value) -> {
>   if (value instanceof List) {
> return ((List) value).toArray();
>   }
>   if (value instanceof Map) {
> var obj = JsPropertyMap.of();
> ((Map) value).forEach((k, v) -> obj.set(k, v));
> return obj;
>   }
>   if (value instanceof Date) {
> return ((Date) value).getTime(); // pass that to JsDate.create() if 
> you prefer an ISO-formatted String rather than the timestamp
>   }
>   if (value instanceof Integer) {
> return ((Integer) value).doubleValue();
>   }
>   return value;
> };
>  
> This is all totally untested (also note that I haven't actually written 
> GWT code for years, this is all based on memory and the javadocs)
>
> Also I found this project updated for GWT 2.9.0 and java 11  
> https://github.com/jp-solutions/gwt-interop-utils . it’s seem goof enough 
> for my use case,  i’ll try out and let you know it.
>
> Not sure what it actually brings on top of plain old JsInterop Base or 
> Elemental Core…
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/c88b2e0c-0883-4ff1-b9a0-1d52d9040158n%40googlegroups.com.


Re: JSInterop and "JSON.stringify" method return "Converting circular structure to JSON"

2024-05-22 Thread Thomas Broyer


On Wednesday, May 22, 2024 at 12:43:56 PM UTC+2 tenti...@gmail.com wrote:

I misunderstood the documentation... ty for the clarification Thomas can 
you give me some confirmations.

The Date issue, When you say to use the JsDate do you mean the one in the 
elemental2 package (elemental2.core.JsDate) or in the gwt core (
com.google.gwt.core.client.JsDate) ?

Any one of them, anything that directly maps to a native JS Date object.
 

So for the Date issue i just enough to replace this code :

@JsProperty *public* *native* *Date* getDataRepertorioDocumento();

 

@JsProperty *public* *native* *void* setDataRepertorioDocumento(*Date* 
dataRepertorioDocumento);

 

With:

@JsProperty *public* *native* Js*Date* getDataRepertorioDocumento();

 

@JsProperty *public* *native* *void* setDataRepertorioDocumento(*JsDate* 
dataRepertorioDocumento);

 

Right ?

Yes.
(note that it works for serializing because a JS Date object has a toJSON() 
method that returns its toISOString(), but it won't work for parsing JSON, 
for that you will have to pass a *reviver* function to JSON.parse() that 
will have to be aware of your object structure to know that the 
dataRepertorioDocumento property value needs to be parsed to a Date object, 
or use a @JsOverlay getter/setter pair that will serialize/parse the 
java.util.Date or JsDate value to/from the JSON representation you want, 
same as List and Map)

I also missed an instance of Integer in your objects, this will have to be 
changed to Double.
 

For the "List" and "Map" problem, i will probably try to use some 
@JsOverlay instead to use a second argument  on the JSON.stringify by the 
way can you point me out some example (i'm not very skilled with this 
library) ?


Could be as simple as (note that a copy is made each time the getter or 
setter is called):
ReferenzaDTOGWT[] nodeIdAllegatti;
// This could also use Elemental's JsArrayLike.asList()
@JsOverlay public List getNodeIdAllegatti() { return 
List.of(this.nodeIdAllegatti); }
@JsOverlay public void setNodeIdAllegatti(List 
nodeIdAllegatti) { this.nodeIdAllegatti = nodeIdAllegatti.toArray(new 
ReferenzaDTOGWT[nodeAllegatti.size()]); }

JsPropertyMap errors;
@JsOverlay public Map getErrors() {
  var ret = new HashMap();
  errors.forEach(key -> ret.put(ret, errors.get(key)));
  return ret;
}
@JsOverlay public setErrors(Map errors) {
  var obj = JsPropertyMap.of();
  errors.forEach((key, value) -> obj.set(key, value));
  this.errors = obj;
}

Of course for the Map> mappaAltriMetadati 
you'd have to also transform each List.

The JSON.stringify replacer could look like:
JSONType.StringifyReplacerFn replacer = (key, value) -> {
  if (value instanceof List) {
return ((List) value).toArray();
  }
  if (value instanceof Map) {
var obj = JsPropertyMap.of();
((Map) value).forEach((k, v) -> obj.set(k, v));
return obj;
  }
  if (value instanceof Date) {
return ((Date) value).getTime(); // pass that to JsDate.create() if you 
prefer an ISO-formatted String rather than the timestamp
  }
  if (value instanceof Integer) {
return ((Integer) value).doubleValue();
  }
  return value;
};
 
This is all totally untested (also note that I haven't actually written GWT 
code for years, this is all based on memory and the javadocs)

Also I found this project updated for GWT 2.9.0 and java 11  
https://github.com/jp-solutions/gwt-interop-utils . it’s seem goof enough 
for my use case,  i’ll try out and let you know it.

Not sure what it actually brings on top of plain old JsInterop Base or 
Elemental Core…

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/fb1a696c-7f35-4f8a-8208-d88ff8f15fc9n%40googlegroups.com.


Re: JSInterop and "JSON.stringify" method return "Converting circular structure to JSON"

2024-05-22 Thread Marco Tenti (IoProgrammo88)


I misunderstood the documentation... ty for the clarification Thomas can 
you give me some confirmations.

The Date issue, When you say to use the JsDate do you mean the one in the 
elemental2 package (elemental2.core.JsDate) or in the gwt core (
com.google.gwt.core.client.JsDate) ?

So for the Date issue i just enough to replace this code :

@JsProperty *public* *native* *Date* getDataRepertorioDocumento();

 

@JsProperty *public* *native* *void* setDataRepertorioDocumento(*Date* 
dataRepertorioDocumento);

 

With:

@JsProperty *public* *native* Js*Date* getDataRepertorioDocumento();

 

@JsProperty *public* *native* *void* setDataRepertorioDocumento(*JsDate* 
dataRepertorioDocumento);

 

Right ?

 

For the "List" and "Map" problem, i will probably try to use some 
@JsOverlay instead to use a second argument  on the JSON.stringify by the 
way can you point me out some example (i'm not very skilled with this 
library) ?  
Also I found this project updated for GWT 2.9.0 and java 11  
https://github.com/jp-solutions/gwt-interop-utils 
. it’s seem goof enough for my use case,  i’ll try out and let you know it. 

Il giorno mercoledì 22 maggio 2024 alle 11:50:10 UTC+2 Vassilis Virvilis ha 
scritto:

> or passing a @JsFunction to JSON.stringify() as its second argument 
>
>
> I wish I knew that some time before...
>  
> -- 
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/c3bf1105-8329-431a-a42d-97ce7b4871e8n%40googlegroups.com.


Re: JSInterop and "JSON.stringify" method return "Converting circular structure to JSON"

2024-05-22 Thread Vassilis Virvilis
>
> or passing a @JsFunction to JSON.stringify() as its second argument


I wish I knew that some time before...

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjExeTQcBh9nHaUpqVYFzjjw%3DVQqvth7g3ZEjE2NoAdYVjg%40mail.gmail.com.


Re: GWT + EMF + JSON

2020-10-26 Thread Rogelio Flores
I know nothing about EMF,  or emf-json, but it seems to me that you need to 
do it this way:

https://emfjson.github.io/projects/gwt/latest/

(using emfjson-gwt)

On Friday, October 23, 2020 at 7:10:31 AM UTC-6 tonio@gmail.com wrote:

> Hi all,
> I am using GWT with EMF and I want write files on client side containing 
> description of some EMF object with the JSON format. For this purpose I use 
> EMFJson tool  (https://emfjson.github.io/) with the following code but I 
> can't write the file,. Have you an idea?
>
> Here is the code:
>
> // As of here we preparing to save the model content
> ResourceSet resSet = new ResourceSetImpl();
> // Register the XMI resource factory for the * extension
> resSet.getPackageRegistry()
> .put(EcorePackage.eNS_URI,EcorePackage.eINSTANCE);
>
> resSet.getResourceFactoryRegistry()
> .getExtensionToFactoryMap()
> .put("*", new JsonResourceFactory());
>
> // Obtain a new resource set
> 
> resSet.getURIConverter().getURIHandlers().add(new 
> LocalStorageHandler());
>
> // create a resource
> URI uri = URI.createURI("file:///" + "D:/Spottest.json");
> GWT.log(uri.toString());
> Resource resource = resSet.createResource(uri);
> // Get the first model element and cast it to the right type,
> // everything is hierarchical included in this first node
> resource.getContents().add(custom);
>
> // now save the content.
> // resource.save(Collections.EMPTY_MAP);
> try {
> resource.save(Collections.EMPTY_MAP);
> } catch (Exception e) {
> GWT.log("Pb saved " + e.getMessage());
> }
>
> Thanks a lot for your help.
>
> Antonio
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/14617e6b-2d62-4650-ad02-020f1e899643n%40googlegroups.com.


GWT + EMF + JSON

2020-10-23 Thread Guillen Antonio
Hi all,
I am using GWT with EMF and I want write files on client side containing 
description of some EMF object with the JSON format. For this purpose I use 
EMFJson tool  (https://emfjson.github.io/) with the following code but I 
can't write the file,. Have you an idea?

Here is the code:

// As of here we preparing to save the model content
ResourceSet resSet = new ResourceSetImpl();
// Register the XMI resource factory for the * extension
resSet.getPackageRegistry()
.put(EcorePackage.eNS_URI,EcorePackage.eINSTANCE);

resSet.getResourceFactoryRegistry()
.getExtensionToFactoryMap()
.put("*", new JsonResourceFactory());

// Obtain a new resource set

resSet.getURIConverter().getURIHandlers().add(new 
LocalStorageHandler());

// create a resource
URI uri = URI.createURI("file:///" + "D:/Spottest.json");
GWT.log(uri.toString());
Resource resource = resSet.createResource(uri);
// Get the first model element and cast it to the right type,
// everything is hierarchical included in this first node
resource.getContents().add(custom);

// now save the content.
// resource.save(Collections.EMPTY_MAP);
try {
resource.save(Collections.EMPTY_MAP);
} catch (Exception e) {
GWT.log("Pb saved " + e.getMessage());
}

Thanks a lot for your help.

Antonio

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/56b08495-9c94-4e83-8a7e-470ea05f4b77n%40googlegroups.com.


Re: Please fix broken text formatting in "Retrieving JSON" tutorial

2018-10-23 Thread Craig Mitchell
I think you can do it yourself.  Edit the page (or go here: 
https://github.com/gwtproject/gwt-site/edit/master/src/main/markdown/doc/latest/tutorial/JSON.md
 
)  Then do a pull request with the fix.  :-)


On Tuesday, 23 October 2018 02:35:49 UTC+11, Юрий Суворов wrote:
>
> Please fix broken text formatting in "Retrieving JSON" tutorial
>
> http://www.gwtproject.org/doc/latest/tutorial/JSON.html
> in paragraph "Building a custom HTTP request"in paragraph "Modify the 
> updateTable method"
>

-- 
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+unsubscr...@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.


Please fix broken text formatting in "Retrieving JSON" tutorial

2018-10-22 Thread Юрий Суворов
Please fix broken text formatting in "Retrieving JSON" tutorial

http://www.gwtproject.org/doc/latest/tutorial/JSON.html
in paragraph "Building a custom HTTP request"in paragraph "Modify the 
updateTable method"

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-22 Thread Ignacio Baca Moreno-Torres
You really should try to avoid inheritance in your JsInterop DTOs. But,
hehe there are always someplace where you need or are forced to use it, in
that case, this is what we are currently using to get "inheritance" working
in the server side and the client side using DTOs:
https://gist.github.com/ibaca/89a2056a862a15c24cb93cdcff908b1f

JSON does not have inheritance, nor types (uhm actually all objects are
Object...), so the visitor strategy mitigates the problem, as this is the
DTO, so the transfer layer, this should not affect your server. Just use
always the factories in both sides and do not continue adding complexity or
at some point, you should stop using JsInterop DTOs and use an actual Java
-> JSON mapper like gwt-jackson[generator|apt].

On Mon, May 21, 2018 at 3:04 AM Ahmad Bawaneh <aka...@gmail.com> wrote:

> As long as you can limit your classes to jstypes - double, arrays, jsDate
> ...etc- this could be the right choice, but when the classes are shared
> with the server you might end up with JsType for each bean in the server,
> or you can use a lib that allows you to share the bean between the client
> and server.
>
> --
> 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+unsubscr...@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.
>

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-20 Thread Ahmad Bawaneh
As long as you can limit your classes to jstypes - double, arrays, jsDate 
...etc- this could be the right choice, but when the classes are shared with 
the server you might end up with JsType for each bean in the server, or you can 
use a lib that allows you to share the bean between the client and server.

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-20 Thread Nándor Előd Fekete
I needed portable code between client/server and polymorphism (through { 
'type': 'SomeTypeIdentifier', ...other properties...}). Is there some 
straightforward way to do that with jsinterop annotations?

On Monday, May 21, 2018 at 12:43:59 AM UTC+2, Thomas Broyer wrote:
>
> How about "just" using @JsType classes?

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-20 Thread Thomas Broyer
How about "just" using @JsType classes?

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-20 Thread Ahmad Bawaneh
Thank you Nándor Előd Fekete for pointing out to my gwt-jackson-apt lib, i 
would like also to add that my lib is using Annotation processors instead 
of reflection and generators, and you can also use the same object mapper 
for both client side and server side, i would really love to have any kind 
of feedback, feature requests, issues in the github repo.

Thanks

On Saturday, May 19, 2018 at 11:07:35 PM UTC+3, richip wrote:
>
> Is there support for JSON-B or any other JSON-object binding API in GWT? 
> If not, is it possible to implement this without reflection? I wouldn't 
> mind taking a stab at it, but am not sure how I'd do it without Java 
> reflection. The goal is to call a R
>

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-20 Thread Nándor Előd Fekete
I had great success with https://github.com/nmorel/gwt-jackson, which is a 
json library written for gwt that emulates much of jackson's functionality. 
But note that it uses gwt generator infrastructure and hence is not 
forward-compatible with future GWT3.
There's also https://github.com/vegegoku/gwt-jackson-apt that should be 
forward compatible with GWT3, but I haven't tried it out yet. Check their 
roadmap for a quick picture on supported/not-yet-supported 
features: https://github.com/vegegoku/gwt-jackson-apt#road-map. Instagram 
also has something, but I haven't tried that 
either: https://github.com/Instagram/ig-json-parser

On Saturday, May 19, 2018 at 10:09:38 PM UTC+2, richip wrote:
>
>
>
> On Saturday, 19 May 2018 14:07:35 UTC-6, richip wrote:
>>
>> Is there support for JSON-B or any other JSON-object binding API in GWT? 
>> If not, is it possible to implement this without reflection? I wouldn't 
>> mind taking a stab at it, but am not sure how I'd do it without Java 
>> reflection. The goal is to call a RESTful service passing a Java object and 
>> getting a Java object in response. All nice and Java-like.
>>
>

-- 
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+unsubscr...@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.


Re: GWT JSON-B

2018-05-19 Thread richip


On Saturday, 19 May 2018 14:07:35 UTC-6, richip wrote:
>
> Is there support for JSON-B or any other JSON-object binding API in GWT? 
> If not, is it possible to implement this without reflection? I wouldn't 
> mind taking a stab at it, but am not sure how I'd do it without Java 
> reflection. The goal is to call a RESTful service passing a Java object and 
> getting a Java object in response. All nice and Java-like.
>

-- 
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+unsubscr...@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.


GWT JSON-B

2018-05-19 Thread richip
Is there support for JSON-B or any other JSON-object binding API in GWT? If 
not, is it possible to implement this without reflection? I wouldn't mind 
taking a stab at it, but am not sure how I'd do it without Java reflection. 
The goal is to call a R

-- 
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+unsubscr...@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.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2018-01-11 Thread Ahmad Bawaneh

I am glad to announce the latest jackson-apt that provide support for using 
the same mapper instance on both client side and server side, finally you 
can annotate the type in the shared module and generate a mapper into the 
shared module and use it in both client code and server code, sample have 
been included in the repository and a snapshot is now avialble, please read 
the README. file for the new dependencies. :smile:

https://github.com/vegegoku/gwt-jackson-apt

also you can join me in the gwt-jackson-apt channel for discussions, 
feedback, questions, opinions.. and what ever you think is interesting.. 
:smiley:

https://gitter.im/domino-gwt/Gwt-jackson-apt

On Monday, December 11, 2017 at 2:25:04 PM UTC+2, Thomas Broyer wrote:
>
> Hi all,
>
> Following up on 
> https://github.com/gwtproject/gwt/issues/9484#issuecomment-277216304, 
> I've been toying around to build a new JSON library for GWT.
> Note that my goal is to have a lightweight library that could be used both 
> on the client-side with GWT (and then j2cl), and on the server-side or in 
> any JVM; and "mapping" to/from POJOs is (currently) out of scope.
>
> What do you think would be the best API?
>
>
>- Same as com.google.gwt.json.
>This API is IMO verbose, and is based on wrapper objects that add 
>runtime overhead.
>- Same as elemental.json, except for JsonNull which goes away 
>(represented by a Java 'null' and interchangeable with 'undefined').
>Lighter-weight, both in terms of API verbosity and runtime overhead 
>(no wrapper object).
>Based on type coercion (you can ask every JsonValue to be returned as 
>a boolean, double, or String, and value will be coerced accordingly).
>elemental.json "JRE" types are also usable on client-side, and can be 
>transported through GWT-RPC; I believe this is an aspect that we cannot 
>preserve.
>- Similar to jsinterop-base's Any, JsPropertyMap and JsArrayLike (for 
>JsonValue, JsonObject and JsonArray respectively), and using Java String 
>and primitives for other value types; and probably with the addition of a 
>JsonType enum (or isXxx methods) on Any/JsonValue to be able to tell value 
>types apart before you call the (throwing) asXxx methods.
>This is actually similar to elemental.json but without the 
>JsonBoolean, JsonNumber, and JsonString types; and it throws rather than 
>coercing values.
>This could even go farther and directly use JsonValue[] instead of 
>JsonArray.
>    - Something else?
>
> One question also is whether this should be used for consuming JSON 
> mostly, or also for creating JSON (you'd generally use POJOs and serialize 
> them to JSON I believe, but there may be cases where you want to create a 
> dynamic structure that you cannot easily represent as a tree of POJOs), 
> and/or "updating/modifying JSON" (parse, update, stringify).
>
> Fwiw, this would also be a good opportunity to shape how a cross-platform 
> library would be developed in terms of project layout and tooling (in both 
> Gradle and Maven).
>
> Wrt the JVM/server-side support, what JSON parsing library should be used? 
> I was heading towards the lightweight Moshi from Square, but I believe 
> there could possibly be several "adapters" for Moshi, GSON, Jackson, etc. 
> (and even org.json's JsonTokenizer/JsonStringer)
>

-- 
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/f7d51867-6062-4a37-98f6-e0ec8f03681a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-27 Thread Ahmad Bawaneh
Hi
I have been working on an adaptation of gwt-jackson that uses APT instead 
of generators

https://github.com/vegegoku/gwt-jackson-apt

now i have plans to support using the same API for both client side and 
server side and want to consider the JsXxxx types as supported types for 
Serialization/Deserialization.

If anyone is interested i welcome any type of  feedback

On Monday, December 11, 2017 at 2:25:04 PM UTC+2, Thomas Broyer wrote:
>
> Hi all,
>
> Following up on 
> https://github.com/gwtproject/gwt/issues/9484#issuecomment-277216304, 
> I've been toying around to build a new JSON library for GWT.
> Note that my goal is to have a lightweight library that could be used both 
> on the client-side with GWT (and then j2cl), and on the server-side or in 
> any JVM; and "mapping" to/from POJOs is (currently) out of scope.
>
> What do you think would be the best API?
>
>
>- Same as com.google.gwt.json.
>This API is IMO verbose, and is based on wrapper objects that add 
>runtime overhead.
>- Same as elemental.json, except for JsonNull which goes away 
>(represented by a Java 'null' and interchangeable with 'undefined').
>Lighter-weight, both in terms of API verbosity and runtime overhead 
>(no wrapper object).
>Based on type coercion (you can ask every JsonValue to be returned as 
>a boolean, double, or String, and value will be coerced accordingly).
>elemental.json "JRE" types are also usable on client-side, and can be 
>transported through GWT-RPC; I believe this is an aspect that we cannot 
>preserve.
>- Similar to jsinterop-base's Any, JsPropertyMap and JsArrayLike (for 
>JsonValue, JsonObject and JsonArray respectively), and using Java String 
>and primitives for other value types; and probably with the addition of a 
>JsonType enum (or isXxx methods) on Any/JsonValue to be able to tell value 
>types apart before you call the (throwing) asXxx methods.
>This is actually similar to elemental.json but without the 
>JsonBoolean, JsonNumber, and JsonString types; and it throws rather than 
>coercing values.
>This could even go farther and directly use JsonValue[] instead of 
>JsonArray.
>    - Something else?
>
> One question also is whether this should be used for consuming JSON 
> mostly, or also for creating JSON (you'd generally use POJOs and serialize 
> them to JSON I believe, but there may be cases where you want to create a 
> dynamic structure that you cannot easily represent as a tree of POJOs), 
> and/or "updating/modifying JSON" (parse, update, stringify).
>
> Fwiw, this would also be a good opportunity to shape how a cross-platform 
> library would be developed in terms of project layout and tooling (in both 
> Gradle and Maven).
>
> Wrt the JVM/server-side support, what JSON parsing library should be used? 
> I was heading towards the lightweight Moshi from Square, but I believe 
> there could possibly be several "adapters" for Moshi, GSON, Jackson, etc. 
> (and even org.json's JsonTokenizer/JsonStringer)
>

-- 
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/0717717c-786b-46ad-b89c-c5c29c3b96f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-17 Thread 'Alexander Bertram' via GWT Contributors
The problem with most existing APIs is that they tend to use polymorphism, 
and expressions like "value instanceof JsonArray". This makes it hard to 
map to a plain Javascript object.

After much frustration, we have recently rolled our own json library, that 
combines the old JSON elemental library, our Gson-gwt library 
(https://github.com/akbertram/gson-gwt) and @JsTypes.

We introduce a single interface, JsonValue, which has a server-side 
implementation based on I think Json.org, and client-side implementation 
that maps directly to plain JavaScript objects:
https://github.com/akbertram/gson-gwt

This means that you can cast a JsonValue directly to a type annotated with 

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")

on the client side via simple assignment and on the server side using 
reflection, with a common API (Json.fromJson)

It's very poorly documented and still has a lot of left over cruft from the 
original sources, but it's working well and we'll continue to develop it.

Sources are here:
https://github.com/bedatadriven/activityinfo/tree/production/tools/json

If any one is interested in working on it, we'll spin out to a seperate 
repo with an Apache license.

Best,
Alex

On Sunday, December 17, 2017 at 5:55:29 AM UTC+1, Goktug Gokdogan wrote:
>
> Inline with what others asked; I think it is best to start with emulating 
> an existing established API instead of introducing a new proprietary API 
> - assuming they could be emulated with a reasonable performance.
>
>
> On Sat, Dec 16, 2017 at 8:24 AM, Thomas Broyer <t.br...@gmail.com 
> > wrote:
>
>>
>>
>> On Monday, December 11, 2017 at 10:44:07 PM UTC+1, Slava Pankov wrote:
>>>
>>> I think it's better to replicate GSON like API on client side. Another 
>>> option is doing better version of RestyGWT without GWT.create()
>>>
>>
>> Do you mean GSON's JsonElement API, or mapping to POJOs?
>> If the latter, then it's out of scope.
>> (I'm not saying it's not an interesting goal, it's just not the one I'm 
>> pursuing here)
>>
>> -- 
>> 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/12c77fe4-0509-46e3-b1d3-bdcdbe8040fb%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/12c77fe4-0509-46e3-b1d3-bdcdbe8040fb%40googlegroups.com?utm_medium=email_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/f2587822-ffde-431d-909b-84f4191ce24e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-16 Thread 'Goktug Gokdogan' via GWT Contributors
Inline with what others asked; I think it is best to start with emulating
an existing established API instead of introducing a new proprietary API -
assuming they could be emulated with a reasonable performance.


On Sat, Dec 16, 2017 at 8:24 AM, Thomas Broyer  wrote:

>
>
> On Monday, December 11, 2017 at 10:44:07 PM UTC+1, Slava Pankov wrote:
>>
>> I think it's better to replicate GSON like API on client side. Another
>> option is doing better version of RestyGWT without GWT.create()
>>
>
> Do you mean GSON's JsonElement API, or mapping to POJOs?
> If the latter, then it's out of scope.
> (I'm not saying it's not an interesting goal, it's just not the one I'm
> pursuing here)
>
> --
> 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/12c77fe4-0509-
> 46e3-b1d3-bdcdbe8040fb%40googlegroups.com
> 
> .
>
> 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%3DyUA2TR6t%2BgwjCojPg0GYy0o88zvsxqiO5BQ7uNER10cGtfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-16 Thread Thomas Broyer


On Monday, December 11, 2017 at 10:44:07 PM UTC+1, Slava Pankov wrote:
>
> I think it's better to replicate GSON like API on client side. Another 
> option is doing better version of RestyGWT without GWT.create()
>

Do you mean GSON's JsonElement API, or mapping to POJOs?
If the latter, then it's out of scope.
(I'm not saying it's not an interesting goal, it's just not the one I'm 
pursuing here)

-- 
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/12c77fe4-0509-46e3-b1d3-bdcdbe8040fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Which API for a future, modern JSON library?

2017-12-16 Thread Thomas Broyer


On Monday, December 11, 2017 at 9:39:52 PM UTC+1, Peter Donald wrote:
>
> Hi, 
>
> Have you considered the javax.json API?


No, just like I didn't consider org.json.
 

> There are some parts that may 
> not be able to be directly translated but from memory it should mostly 
> work. The "advantage" is that it is a standard that is starting to 
> gain traction and will likely be present in lots more APIs as more of 
> the EE stack adopts it. The "disadvantage" is that the api is a bit 
> more primitive and it evolves slowly. It could probably be done with 
> just @JsOverlay methods and a few adapter classes.


I think it would mostly involve adapter classes (JsonObject extends Map, 
JsonArray extends List; so they cannot be implemented as native types)
 

> Another 
> disadvantage is that it is an immutable/read-only API. 
>

It's actually not: JsonObjectBuilder and JsonArrayBuilder allow 
constructing values.

-- 
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/5dbdcd27-d141-4b07-935e-4ec5e994ddc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-11 Thread Slava Pankov
I think it's better to replicate GSON like API on client side. Another 
option is doing better version of RestyGWT without GWT.create()

On Monday, December 11, 2017 at 4:25:04 AM UTC-8, Thomas Broyer wrote:
>
> Hi all,
>
> Following up on 
> https://github.com/gwtproject/gwt/issues/9484#issuecomment-277216304, 
> I've been toying around to build a new JSON library for GWT.
> Note that my goal is to have a lightweight library that could be used both 
> on the client-side with GWT (and then j2cl), and on the server-side or in 
> any JVM; and "mapping" to/from POJOs is (currently) out of scope.
>
> What do you think would be the best API?
>
>
>- Same as com.google.gwt.json.
>This API is IMO verbose, and is based on wrapper objects that add 
>runtime overhead.
>- Same as elemental.json, except for JsonNull which goes away 
>(represented by a Java 'null' and interchangeable with 'undefined').
>Lighter-weight, both in terms of API verbosity and runtime overhead 
>(no wrapper object).
>Based on type coercion (you can ask every JsonValue to be returned as 
>a boolean, double, or String, and value will be coerced accordingly).
>elemental.json "JRE" types are also usable on client-side, and can be 
>transported through GWT-RPC; I believe this is an aspect that we cannot 
>preserve.
>- Similar to jsinterop-base's Any, JsPropertyMap and JsArrayLike (for 
>JsonValue, JsonObject and JsonArray respectively), and using Java String 
>and primitives for other value types; and probably with the addition of a 
>JsonType enum (or isXxx methods) on Any/JsonValue to be able to tell value 
>types apart before you call the (throwing) asXxx methods.
>This is actually similar to elemental.json but without the 
>JsonBoolean, JsonNumber, and JsonString types; and it throws rather than 
>coercing values.
>This could even go farther and directly use JsonValue[] instead of 
>JsonArray.
>    - Something else?
>
> One question also is whether this should be used for consuming JSON 
> mostly, or also for creating JSON (you'd generally use POJOs and serialize 
> them to JSON I believe, but there may be cases where you want to create a 
> dynamic structure that you cannot easily represent as a tree of POJOs), 
> and/or "updating/modifying JSON" (parse, update, stringify).
>
> Fwiw, this would also be a good opportunity to shape how a cross-platform 
> library would be developed in terms of project layout and tooling (in both 
> Gradle and Maven).
>
> Wrt the JVM/server-side support, what JSON parsing library should be used? 
> I was heading towards the lightweight Moshi from Square, but I believe 
> there could possibly be several "adapters" for Moshi, GSON, Jackson, etc. 
> (and even org.json's JsonTokenizer/JsonStringer)
>

-- 
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/f0aa4880-8c0a-4a50-bfd3-f59b29f57dbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Which API for a future, modern JSON library?

2017-12-11 Thread Peter Donald
Hi,

Have you considered the javax.json API? There are some parts that may
not be able to be directly translated but from memory it should mostly
work. The "advantage" is that it is a standard that is starting to
gain traction and will likely be present in lots more APIs as more of
the EE stack adopts it. The "disadvantage" is that the api is a bit
more primitive and it evolves slowly. It could probably be done with
just @JsOverlay methods and a few adapter classes. Another
disadvantage is that it is an immutable/read-only API.

As for json writing - We tend to use @JsType annotated classes and
have yet to come up with a use case where we would need to drop down
to JsPropertyMap.

-- 
Cheers,

Peter Donald

-- 
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/CACiKNc6_RvyT7RaQ8r87bXcexVvGB%2BmtFCiATZrY-aNcB%2BYKEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-11 Thread jay
Out of curiosity, why not use the org.json API?

jay

On Monday, December 11, 2017 at 8:13:40 AM UTC-8, Thomas Broyer wrote:
>
>
>
> On Monday, December 11, 2017 at 4:01:41 PM UTC+1, Colin Alworth wrote:
>>
>> Thanks Thomas, I'm excited to see where this will lead.
>>
>> Can you talk a little more about plans POJO support, as none of the three 
>> existing options have any? Would you envision a wrapping tool that looks 
>> like AutoBean/gwt-jackson, and where on that continuum are you thinking 
>> (autobean is as late as possible, and generic enough to handle xml or other 
>> underlying data formats, gwt-jackson parses then copies all json tree nodes 
>> directly to bean values)? I also know there have been some experiments 
>> around passing a reviver func to JSON.parse that could be interesting here. 
>> Any thoughts on handling collections, whether to go with java.util, or try 
>> for something shared js/jvm and only used within this library?
>>
>
> No plan. at all. really.
> Might even never be in scope.
>
> What would look the closest to a plan would be to somehow expose the "raw" 
> objects so you could "cast" them to jsinterop native types (collections are 
> an issue there). And by using an API like " T cast(Class clazz)", a 
> JVM adapter could use its own logic to do the mapping into new objects 
> (note that JS and JVM would have different behavior wrt updating the 
> objects) Raw objects could possibly also be fed into "wrappers" like 
> AutoBeans (btw, if it weren't for the –understandable– JsInterop limitation 
> that a native type cannot implement/extend a non-jstype interface, 
> AutoBeans would probably not have to be wrappers, but only native or 
> overlay methods and WeakMap 
> <https://kangax.github.io/compat-table/es6/#test-WeakMap> for reified 
> types; if the "schema" wasn't the Java interface you actually use in your 
> code, those could easily be generated).
>

-- 
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/26f089cc-0eca-42ea-b14d-a236bd6848aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Re: Which API for a future, modern JSON library?

2017-12-11 Thread Colin Alworth
Thanks Thomas, I'm excited to see where this will lead.

Can you talk a little more about plans POJO support, as none of the three 
existing options have any? Would you envision a wrapping tool that looks 
like AutoBean/gwt-jackson, and where on that continuum are you thinking 
(autobean is as late as possible, and generic enough to handle xml or other 
underlying data formats, gwt-jackson parses then copies all json tree nodes 
directly to bean values)? I also know there have been some experiments 
around passing a reviver func to JSON.parse that could be interesting here. 
Any thoughts on handling collections, whether to go with java.util, or try 
for something shared js/jvm and only used within this library?

As a replacement for elemental.json or c.g.g.json, I would personally 
imagine only the json node tree support. I'm aware that work is ongoing 
already to update gwt-jackson to move to APT, and am considering trying 
AutoBeans myself, mostly because i find it so handy when I want to write 
strongly typed java around plain json.

My only thought on adapter vs starting with a specific jre parser is that 
there is a lot of flexibility/depth already in this project - perhaps just 
keep the internals as private as possible, and leave room for such adapters 
in vers 2?

On Monday, December 11, 2017 at 6:25:04 AM UTC-6, Thomas Broyer wrote:
>
> Hi all,
>
> Following up on 
> https://github.com/gwtproject/gwt/issues/9484#issuecomment-277216304, 
> I've been toying around to build a new JSON library for GWT.
> Note that my goal is to have a lightweight library that could be used both 
> on the client-side with GWT (and then j2cl), and on the server-side or in 
> any JVM; and "mapping" to/from POJOs is (currently) out of scope.
>
> What do you think would be the best API?
>
>
>- Same as com.google.gwt.json.
>This API is IMO verbose, and is based on wrapper objects that add 
>runtime overhead.
>- Same as elemental.json, except for JsonNull which goes away 
>(represented by a Java 'null' and interchangeable with 'undefined').
>Lighter-weight, both in terms of API verbosity and runtime overhead 
>(no wrapper object).
>Based on type coercion (you can ask every JsonValue to be returned as 
>a boolean, double, or String, and value will be coerced accordingly).
>elemental.json "JRE" types are also usable on client-side, and can be 
>transported through GWT-RPC; I believe this is an aspect that we cannot 
>preserve.
>- Similar to jsinterop-base's Any, JsPropertyMap and JsArrayLike (for 
>JsonValue, JsonObject and JsonArray respectively), and using Java String 
>and primitives for other value types; and probably with the addition of a 
>JsonType enum (or isXxx methods) on Any/JsonValue to be able to tell value 
>types apart before you call the (throwing) asXxx methods.
>This is actually similar to elemental.json but without the 
>JsonBoolean, JsonNumber, and JsonString types; and it throws rather than 
>coercing values.
>This could even go farther and directly use JsonValue[] instead of 
>JsonArray.
>    - Something else?
>
> One question also is whether this should be used for consuming JSON 
> mostly, or also for creating JSON (you'd generally use POJOs and serialize 
> them to JSON I believe, but there may be cases where you want to create a 
> dynamic structure that you cannot easily represent as a tree of POJOs), 
> and/or "updating/modifying JSON" (parse, update, stringify).
>
> Fwiw, this would also be a good opportunity to shape how a cross-platform 
> library would be developed in terms of project layout and tooling (in both 
> Gradle and Maven).
>
> Wrt the JVM/server-side support, what JSON parsing library should be used? 
> I was heading towards the lightweight Moshi from Square, but I believe 
> there could possibly be several "adapters" for Moshi, GSON, Jackson, etc. 
> (and even org.json's JsonTokenizer/JsonStringer)
>

-- 
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/3c1d1f76-6da7-4a5f-bda0-7ddcbe2eaddd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Which API for a future, modern JSON library?

2017-12-11 Thread Thomas Broyer
Hi all,

Following up 
on https://github.com/gwtproject/gwt/issues/9484#issuecomment-277216304, 
I've been toying around to build a new JSON library for GWT.
Note that my goal is to have a lightweight library that could be used both 
on the client-side with GWT (and then j2cl), and on the server-side or in 
any JVM; and "mapping" to/from POJOs is (currently) out of scope.

What do you think would be the best API?


   - Same as com.google.gwt.json.
   This API is IMO verbose, and is based on wrapper objects that add 
   runtime overhead.
   - Same as elemental.json, except for JsonNull which goes away 
   (represented by a Java 'null' and interchangeable with 'undefined').
   Lighter-weight, both in terms of API verbosity and runtime overhead (no 
   wrapper object).
   Based on type coercion (you can ask every JsonValue to be returned as a 
   boolean, double, or String, and value will be coerced accordingly).
   elemental.json "JRE" types are also usable on client-side, and can be 
   transported through GWT-RPC; I believe this is an aspect that we cannot 
   preserve.
   - Similar to jsinterop-base's Any, JsPropertyMap and JsArrayLike (for 
   JsonValue, JsonObject and JsonArray respectively), and using Java String 
   and primitives for other value types; and probably with the addition of a 
   JsonType enum (or isXxx methods) on Any/JsonValue to be able to tell value 
   types apart before you call the (throwing) asXxx methods.
   This is actually similar to elemental.json but without the JsonBoolean, 
   JsonNumber, and JsonString types; and it throws rather than coercing values.
   This could even go farther and directly use JsonValue[] instead of 
   JsonArray.
   - Something else?

One question also is whether this should be used for consuming JSON mostly, 
or also for creating JSON (you'd generally use POJOs and serialize them to 
JSON I believe, but there may be cases where you want to create a dynamic 
structure that you cannot easily represent as a tree of POJOs), and/or 
"updating/modifying JSON" (parse, update, stringify).

Fwiw, this would also be a good opportunity to shape how a cross-platform 
library would be developed in terms of project layout and tooling (in both 
Gradle and Maven).

Wrt the JVM/server-side support, what JSON parsing library should be used? 
I was heading towards the lightweight Moshi from Square, but I believe 
there could possibly be several "adapters" for Moshi, GSON, Jackson, etc. 
(and even org.json's JsonTokenizer/JsonStringer)

-- 
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/8798ff67-2a53-462b-95f7-2e2d9e953b71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Thomas Broyer


On Wednesday, November 15, 2017 at 11:19:56 AM UTC+1, Jens wrote:
>
>
> Thanks for the early response. Can you give an example of getData(String 
>> key) method.
>>
>
> Sure, assuming your values are only strings you can do
>
> public native String getData(String key) /*-{
>   return this.data[key];
> }-*/;
>
> If your values can also be number, boolean, JS Object you need additional 
> methods, possibly also doing some type checking. 
>
> Given that JSNI won't work in future GWT I would really take a look at 
> jsinterop.base.JsPropertyMap which is a generic class to work on JavaScript 
> objects.
>
> https://github.com/google/jsinterop-base/blob/master/java/jsinterop/base/JsPropertyMap.java
>

@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL)
public class Result {
  String[] columns; // or JsArrayLike
  JsPropertyMap data;
}

That should be enough (and much much simpler/shorter than with JSNI).

Migrating a JSNI getData(String):String to JsInterop would be quite easy 
too:

@JsType(isNative = true, name = "Object", namespace = JsPackage.GLOBAL)
public class Result {
  @JsProperty public native String[] getColumns();
  @JsOverlay public String getData(String key) {
return getData().get(key);
  }
  @JsProperty private native JsPropertyMap getData();
}



-- 
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+unsubscr...@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.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Kirill Prazdnikov
JSNI is not recommended. 

If you can assign types, go with JsInterop, if not -> then you have a map 
String->?

-- 
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+unsubscr...@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.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Abhishek Banerjee
Thanks a bunch!!

On Wednesday, 15 November 2017 15:49:56 UTC+5:30, Jens wrote:
>
>
> Thanks for the early response. Can you give an example of getData(String 
>> key) method.
>>
>
> Sure, assuming your values are only strings you can do
>
> public native String getData(String key) /*-{
>   return this.data[key];
> }-*/;
>
> If your values can also be number, boolean, JS Object you need additional 
> methods, possibly also doing some type checking. 
>
> Given that JSNI won't work in future GWT I would really take a look at 
> jsinterop.base.JsPropertyMap which is a generic class to work on JavaScript 
> objects.
>
> https://github.com/google/jsinterop-base/blob/master/java/jsinterop/base/JsPropertyMap.java
>
> -- 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+unsubscr...@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.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Jens


> Thanks for the early response. Can you give an example of getData(String 
> key) method.
>

Sure, assuming your values are only strings you can do

public native String getData(String key) /*-{
  return this.data[key];
}-*/;

If your values can also be number, boolean, JS Object you need additional 
methods, possibly also doing some type checking. 

Given that JSNI won't work in future GWT I would really take a look at 
jsinterop.base.JsPropertyMap which is a generic class to work on JavaScript 
objects.
https://github.com/google/jsinterop-base/blob/master/java/jsinterop/base/JsPropertyMap.java

-- 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+unsubscr...@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.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Abhishek Banerjee
Thanks for the early response. Can you give an example of getData(String 
key) method.

On Wednesday, 15 November 2017 14:49:56 UTC+5:30, Jens wrote:
>
> You can use JSONObject, a custom JavaScriptObject with JSNI getColumns() 
> and getData(String key) methods or use JsPropertyMap from jsinterop.base 
> library.
>
> -- 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+unsubscr...@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.


Re: Dynamic values in json parsing with GWT

2017-11-15 Thread Jens
You can use JSONObject, a custom JavaScriptObject with JSNI getColumns() 
and getData(String key) methods or use JsPropertyMap from jsinterop.base 
library.

-- 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+unsubscr...@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.


Dynamic values in json parsing with GWT

2017-11-15 Thread Abhishek Banerjee


I have a json response like this

{"columns": ["a", "b", "c"], "data": {"a": "some value", "b": "some value", 
"c": "some value"}}

Now here whatever values columns have the same values are used as keys in 
data object. I have to parse this json in GWT client side. As far as I know 
JSNI requires fixed json objects. Is there any way to parse this?

-- 
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+unsubscr...@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.


GWT ClasscastException when casting from java.lang.String(json) to com.google.gwt.core.client.JavascriptObject

2017-11-11 Thread Surinaidu Majji
We are working with the Web application which was developed by using GWT 
and smart gwt project. Currently we are using
GWT-2.5.1 and smart gwt-5.0 in our application.Now we wanted to upgrade our 
smart gwt upgrade to 6.1 from 5.0 but not changed the GWT. 

We got the compilation error with smart-gwt-6.1 with GWT-2.5.0. So we also 
migrated GWT to 2.6.1. Now we are able to compile our application 
successfuly.

We have got the runtime exception like below.

   

 public void transformResponse(Object data) { // data contains json 
string
JavaScriptObject jsObj = (JavascriptObject) data.// This line 
causes the below excepton
}

ClassCastExcetion: java.lang.Strig can not cast to 
com.google.gwt.core.cient.Javascript Object.

This code was working with the earlier versions of smart-gwt and GWT. but 
now it is throwing this exception.

Firstly I was not be able to find any documentation about compatability of 
smart-gwt and gwt. 

Could any body tell me how to solve the above issue and how to handle this 
upgrade of smart gwt. 

-- 
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+unsubscr...@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.


Re: JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Velusamy Velu
Thank you very much! I just can't believe I missed that.

On Thursday, September 22, 2016 at 11:10:15 AM UTC-4, Jens wrote:
>
> Missing "return" statement in your JSNI method. Because you returned 
> nothing, the method returns null automatically.
>
> Also you can use 
>
> ServerResponseJson resp = JsonUtils.safeEvel(jsonString);
>
> which is safer than using JS eval() directly.
>
> -- 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+unsubscr...@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.


Re: JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Jens
Missing "return" statement in your JSNI method. Because you returned 
nothing, the method returns null automatically.

Also you can use 

ServerResponseJson resp = JsonUtils.safeEvel(jsonString);

which is safer than using JS eval() directly.

-- 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+unsubscr...@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.


JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Velusamy Velu


I'm looking for help in converting a JSON to an instance of a POJO with 
embedded objects, on the GWT client side. I'm partially successful but 
unable to convert every piece of the JSON I have.


I have removed all but one working piece of code here to narrow down to the 
problem area. Specifically, my question is why the following method returns 
null?


public final native JsonArray getServerStatusCodeMap() /*-{

// debugger shows serverStatusCodeMap is valid below

this.serverStatusCodeMap; 
}-*/;


The JSON is valid (given below) and I have provided all the relevant code 
in this post. I would greatly appreciate any help.


Here's the JSON:

{
  "idOfSavedObject": "AVc-CQ4OI-SZQb7PIPb_",
  "serverStatusCodeMap": [
{
  "name": "AVc-CTACI-SZQb7PIPcO",
  "value": 202
},
{
  "name": "AVc-CTACI-SZQb7PIPcP",
  "value": 100
}
  ]}

Its JS overlay class is

public class ServerResponseJson extends JavaScriptObject {

protected ServerResponseJson() {}

public static final native ServerResponseJson build(String json) /*-{
return eval('(' + json + ')');
}-*/;

public final native String getIdOfSavedObject() /*-{
return this.idOfSavedObject;
}-*/;

public final native JsonArray getServerStatusCodeMap() /*-{
this.serverStatusCodeMap;
}-*/;}

I debugged and found the method below has the right values

public final native JsonArray getServerStatusCodeMap() /*-{
this.serverStatusCodeMap; // this attribute has the right value, the caller 
of this method gets a null
}-*/;

[image: Screen clip showing the right values for serverStatusCodeMap] 
<http://i.stack.imgur.com/JReyv.jpg>


JsonArray.java

public class JsonArray extends JavaScriptObject {
protected JsonArray() {}

public final native int length() /*-{
return this.length;
}-*/;

public final native E get(int i) /*-{
return this[i];
}-*/;}

the NameNumberJson.java

public class NameNumberJson extends JavaScriptObject {
protected NameNumberJson() {}

public static final native NameNumberJson buildNameNumberJson(String json) 
/*-{
return eval('(' + json + ')');
}-*/;

// Return the whole JSON array, as is
public static final native JsonArray 
getNameNumberJsons(String json) /*-{
return eval('(' + json + ')');
}-*/;

public final native String getName() /*-{
return this.name;
}-*/;

public final native int getValue() /*-{
return this.value;
}-*/;}

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-22 Thread Ignacio Baca Moreno-Torres
"domain object" vs "message payload"; Yes, this is the point. We came from 
RequestFactory which works quite good with "domain object" models, we use 
one model for each type, this model is the same in the server and the 
client, and all views use the same model.

So, responding to the 'JSON object recreation in the client'; JsInterop 
makes trivial Object recreation, you map your messages in a very explicit 
and clean manner having almost zero overhead, but you should take care of 
this "domain object" vs "message payload" model strategy. JsInterop doesn't 
work well with "domain object" models (so questions like how can you return 
a Set or a Map are currently hard to answer, and makes no much sense in the 
"message payload" side), but it will work much better with "message 
payloads". We are getting really good result using plain classes without 
methods. But it's important to think on terms of "message payloads", you 
should try to avoid fancy things, using only primitives (plus Boolean, 
Double and String), arrays or other @JsType models. We end up with lot of 
services like this. This models frequently do not need any special 
annotation, but are so simple that most JSON encoder works correctly 
(Jackson, gson, moshi...) and obviously JsInterop.

@AutoRestGwt
@Path(RESOURCE_TOOLS)
@Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface ToolsRestService {

@GET @Path("build")
Single getBuildInfo();

@JsType(namespace = GLOBAL, name = "Object", isNative = true)
class BuildInfo {
public int buildDate;
public String version;
public String commitId;
public String javaVersion;
}

@GET @Path("system")
Single getSystemInfo();

@JsType(namespace = GLOBAL, name = "Object", isNative = true)
class SystemInfo {
public double startupTime;
public double totalMemory;
    public double freeMemory;
public double usedMemory;
}
}


I like to think of this classes as something like JSON (JavaScript Object 
Notation) but in Java and to define the scheme instead of the object itself 
so JOSN (Java Object Scheme Notation), i.e. a subset of Java just to define 
objects schemes. 

On Saturday, August 20, 2016 at 12:54:24 AM UTC+2, Thomas Broyer wrote:
>
> I think the crux is thinking in terms of messages (payloads) rather than 
> "domain objects". This applies to DTOs vs domain objects too, with RPC or 
> RequestFactory or whatever.

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Thomas Broyer
I think the crux is thinking in terms of messages (payloads) rather than 
"domain objects". This applies to DTOs vs domain objects too, with RPC or 
RequestFactory or whatever.

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
I mean java8 Streams 
(https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html).
 
And I said that is the same as Immutable+FluentIterable because you can use 
Stream.of(values[]). And IMO this makes more sense in a DTO than using the 
interfaces on the collection frameworks (list, set, map, and worst with 
specific types like ArrayList, EnumSet, etc), because whats means a set in 
a DTO (I mean in the JSON), or worst an EnumSet? this information is not 
related to the schema of the transferred data, and I think that this makes 
the encoding/decoding much more complex. And with Streams you can get back 
to the java collection whenever you really need it quite easy, for example 
if you have 'String[] types' an array of enum names of TypeEnum, you can 
get the Set using Stream.of(types).map(TypeEnum::valueOf).colllect(toSet());

On Friday, August 19, 2016 at 8:04:37 PM UTC+2, Vassilis Virvilis wrote:
>
> Thanks for the write up. I would definitely have it in mind.
>
> BTW can you expand a bit on the stream thingy? Is there a link somewhere 
> to read about?
>
> Vassilis
>
> On Fri, Aug 19, 2016 at 8:59 PM, Ignacio Baca Moreno-Torres <
> ign...@bacamt.com > wrote:
>
>> Migrating everything is not a good idea, but you should give a try to 
>> arrays in new models or some parts of your application. We found that we 
>> frequently end up using Immutable collections and FluentIterable, and this 
>> is almost the same that using arrays and streams. As you said, migrating a 
>> whole project is too complicated, but you can just start using and 
>> progressively applying to the whole API if this actually works for you. In 
>> 3 years we past from using RequestFactory, to RestyGWT to almost plain 
>> request + jsinterop (actually autorest-gwt). Maybe using plain objects and 
>> arrays doesn't fit in your project, but you really should try.
>>
>> Emm... and a bit of context; I'm try to justify that the complexity added 
>> during parsing/encoding to support collections and generics really do not 
>> worth (depends on projects) if your API use DTOs and you have streams 
>> available. In our project the DTOs classes end up as a scheme definition, 
>> defining the name and type of each property and with a minimal overhead 
>> during parsing/encoding in JRE, GWT and even Android (
>> https://github.com/ibaca/autorest-nominatim-example/).
>>
>> On Friday, August 19, 2016 at 4:10:30 PM UTC+2, Vassilis Virvilis wrote:
>>>
>>> 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 <
>>> ign...@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 :
>>>>>>>
>&

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
Thanks for the write up. I would definitely have it in mind.

BTW can you expand a bit on the stream thingy? Is there a link somewhere to
read about?

Vassilis

On Fri, Aug 19, 2016 at 8:59 PM, Ignacio Baca Moreno-Torres <
igna...@bacamt.com> wrote:

> Migrating everything is not a good idea, but you should give a try to
> arrays in new models or some parts of your application. We found that we
> frequently end up using Immutable collections and FluentIterable, and this
> is almost the same that using arrays and streams. As you said, migrating a
> whole project is too complicated, but you can just start using and
> progressively applying to the whole API if this actually works for you. In
> 3 years we past from using RequestFactory, to RestyGWT to almost plain
> request + jsinterop (actually autorest-gwt). Maybe using plain objects and
> arrays doesn't fit in your project, but you really should try.
>
> Emm... and a bit of context; I'm try to justify that the complexity added
> during parsing/encoding to support collections and generics really do not
> worth (depends on projects) if your API use DTOs and you have streams
> available. In our project the DTOs classes end up as a scheme definition,
> defining the name and type of each property and with a minimal overhead
> during parsing/encoding in JRE, GWT and even Android (
> https://github.com/ibaca/autorest-nominatim-example/).
>
> On Friday, August 19, 2016 at 4:10:30 PM UTC+2, Vassilis Virvilis wrote:
>>
>> 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 <
>> ign...@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 cla

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
Migrating everything is not a good idea, but you should give a try to 
arrays in new models or some parts of your application. We found that we 
frequently end up using Immutable collections and FluentIterable, and this 
is almost the same that using arrays and streams. As you said, migrating a 
whole project is too complicated, but you can just start using and 
progressively applying to the whole API if this actually works for you. In 
3 years we past from using RequestFactory, to RestyGWT to almost plain 
request + jsinterop (actually autorest-gwt). Maybe using plain objects and 
arrays doesn't fit in your project, but you really should try.

Emm... and a bit of context; I'm try to justify that the complexity added 
during parsing/encoding to support collections and generics really do not 
worth (depends on projects) if your API use DTOs and you have streams 
available. In our project the DTOs classes end up as a scheme definition, 
defining the name and type of each property and with a minimal overhead 
during parsing/encoding in JRE, GWT and even Android 
(https://github.com/ibaca/autorest-nominatim-example/).

On Friday, August 19, 2016 at 4:10:30 PM UTC+2, Vassilis Virvilis wrote:
>
> 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 <
> ign...@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 e

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
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 <
igna...@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+unsubscr...@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+unsubscr...@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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
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+unsubscr...@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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
How about transmitting nested Collections, Map, complex inheritance and
generics?

On Fri, Aug 19, 2016 at 4:30 PM, zakaria amine <zakaria.amin...@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+unsubscr...@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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Jens


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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
I have tried something like: 

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

As mentioned above, I created a JsInterop wrapper for the JSON class in 
javascript :

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

}

After calling : 

  Record record = new Record();
   record.id = "1";
   record.date = "20";
   record.data = "30";

GWT.log(JSON.stringify(record));

I got : 

{"id_1_g$":"1","date_1_g$":"20","data_1_g$":"30"}

I am not sure why does GWT adds _1_g$ to all properties. the solution is to 
annotate properties with @JsProperty(name="property name") 





Le jeudi 18 août 2016 09:33:37 UTC+2, Max Fromberger a écrit :
>
> Hello everybody,
>
> First of all a big THANKS to everyone involved in developing and 
> supporting GWT.
>
> please correct me wherever I am wrong:
>
> In the past you used JsonUtils.safeEval() to create a JavaScriptObject 
> from a JSON String. As i understand it, jsinterop annotations on classes 
> not extending JavaScriptObject are now preferred over JavaScriptObjects.
>
> What is the recommended, future-proof way of having a server-client common 
> class (i.e. package "shared") that can be:
>
> - created and accessed in a JVM servlet
> - created and accessed from the client end
> - serialized to JSON / deserialized from JSON to the specific class on the 
> server (e.g. using GSON)
> - serialized to JSON / deserialized from JSON to the specific class on the 
> client
>
> Background: Using WebSocket Servers to bidirectionally transfer JSONified 
> objects. No GWT-RPC involved.
> Trying to avoid duplicate environment specific classes, boilerplate code 
> etc.
>
> Thanks for every clue and please overlook me not having a native English 
> interface. ;)
>
>
>
> kind regards,
> max
>
>
>

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Thomas Broyer
Or you could use an array instead of a collection.

-- 
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+unsubscr...@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.


Best Practice for JSON object recreation on client

2016-08-18 Thread Luke Last
I use jackson/gson on the server to serialize and then gwt-jackson on the 
client to deserialize a shared pojo. I'm interested in finding out if JsInterop 
gives better performance though. 

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Paul Stockley
I wrote a set of utilities using the new JsInterop capability in 2.8 that 
provides one way of handling JSON. Take a look at the documentation 
here https://github.com/GWTReact/gwt-interop-utils/blob/master/DOCUMENTATION.md

We use Jackson on the server for handling the translation from JSON to Java 
objects

On Thursday, August 18, 2016 at 5:35:34 AM UTC-4, Jens wrote:
>
>
> Why would it? You may want to use JsInterop to call JSON.parse() instead 
>> of using JsonUtils and casts from JavaScriptObject, but I believe it'd just 
>> work otherwise (can't try it ATM though)
>
>
> You can not use a Java Collection as field so you would need some 
> conversion to JsArray that JsInterop / JSON.parse() can handle but 
> otherwise it should work well.
>
> -- 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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Jens


> Why would it? You may want to use JsInterop to call JSON.parse() instead 
> of using JsonUtils and casts from JavaScriptObject, but I believe it'd just 
> work otherwise (can't try it ATM though)


You can not use a Java Collection as field so you would need some 
conversion to JsArray that JsInterop / JSON.parse() can handle but 
otherwise it should work well.

-- 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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Vassilis Virvilis
Generally the GWT guys are careful and I am sure they will provide a way to
migrate. If I understand correctly the mechanism that will replace
generators (GWT.create()) is called APT and is based on annotations. In my
codebase I don't have the need and so I don't really know but I am using
libraries that require some way to create code (self-inspection) such are
resty-gwt, event-binder and gwt-jackson.

I don't know if APT is currently available in GWT but I don't think so. I
believe that APT and GWT generators should co-exist for at least one GWT
release for migration to happen.

For CSS vs GSS I know this is already happening. GSS is available in GWT
2.8 and CSS will be deprecated in the next version,

Vassilis

On Thu, Aug 18, 2016 at 10:50 AM, Max Fromberger 
wrote:

> Hello Vassilis,
>
> thanks for this contribution.
> This raises another question: is there a way to solve the above described
> tasks that is GWT 3 proof and already feasible in GWT 2.8?
>
> kind regards,
> max
>

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Thomas Broyer
Why would it? You may want to use JsInterop to call JSON.parse() instead of 
using JsonUtils and casts from JavaScriptObject, but I believe it'd just work 
otherwise (can't try it ATM though)

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hi Thomas,

wouldn't that still require MyObj to extend JavaScriptObject in order to be 
deserialized on the client?
Thanks for your participation.

Kind regards,
max

Am Donnerstag, 18. August 2016 10:41:28 UTC+2 schrieb Thomas Broyer:
>
> Have you tried something like:
>
> @JsType(isNative=true,namespace=GLOBAL,name="Object")
> class MyObj {
> String str;
> int num;
> }
>

-- 
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+unsubscr...@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.


Best Practice for JSON object recreation on client

2016-08-18 Thread Thomas Broyer
Have you tried something like:

@JsType(isNative=true,namespace=GLOBAL,name="Object")
class MyObj {
String str;
int num;
}

-- 
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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hello Vassilis,

thanks for this contribution.
This raises another question: is there a way to solve the above described 
tasks that is GWT 3 proof and already feasible in GWT 2.8?

kind regards,
max

Am Donnerstag, 18. August 2016 09:45:08 UTC+2 schrieb Vassilis Virvilis:
>
> Hi,
>
> I am using resty-gwt. Resty-gwt had his own (forked from jackson I 
> believe) json serialization classes. But now Rest-gwt is switching to 
> gwt-jackson. I haven't managed to get gwt-jackson to work with my setup 
> (yet) but looks like a valid path forward.
>
> In the server I am using CXF and the normal jackson. I am not saying 
> everything is perfect but most of my objects are transferred without a 
> fuss. In some cases where the object is complicated (e.g. Collection<Map<T, 
> Collection> members or inheritance) I have to provide a custom provider 
> that knows how to deal. However this was a one time pain for me. Now I have 
> forgotten all the terrifying details and it just works.
>
> I am sure there are other solutions like GSON which I don't have any 
> experience with.
>
> Furthermore with the upcoming GWT3 which will deprecate generators all 
> these projects have a scheduled rewrite pending... So who knows?
>
> Vassilis
>
>
>
> On Thu, Aug 18, 2016 at 10:33 AM, Max Fromberger <max.fro...@gmail.com 
> > wrote:
>
>> Hello everybody,
>>
>> First of all a big THANKS to everyone involved in developing and 
>> supporting GWT.
>>
>> please correct me wherever I am wrong:
>>
>> In the past you used JsonUtils.safeEval() to create a JavaScriptObject 
>> from a JSON String. As i understand it, jsinterop annotations on classes 
>> not extending JavaScriptObject are now preferred over JavaScriptObjects.
>>
>> What is the recommended, future-proof way of having a server-client 
>> common class (i.e. package "shared") that can be:
>>
>> - created and accessed in a JVM servlet
>> - created and accessed from the client end
>> - serialized to JSON / deserialized from JSON to the specific class on 
>> the server (e.g. using GSON)
>> - serialized to JSON / deserialized from JSON to the specific class on 
>> the client
>>
>> Background: Using WebSocket Servers to bidirectionally transfer JSONified 
>> objects. No GWT-RPC involved.
>> Trying to avoid duplicate environment specific classes, boilerplate code 
>> etc.
>>
>> Thanks for every clue and please overlook me not having a native English 
>> interface. ;)
>>
>>
>>
>> kind regards,
>> max
>>
>>
>> -- 
>> 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+unsubscr...@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+unsubscr...@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.


Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Vassilis Virvilis
Hi,

I am using resty-gwt. Resty-gwt had his own (forked from jackson I believe)
json serialization classes. But now Rest-gwt is switching to gwt-jackson. I
haven't managed to get gwt-jackson to work with my setup (yet) but looks
like a valid path forward.

In the server I am using CXF and the normal jackson. I am not saying
everything is perfect but most of my objects are transferred without a
fuss. In some cases where the object is complicated (e.g. Collection<Map<T,
Collection> members or inheritance) I have to provide a custom provider
that knows how to deal. However this was a one time pain for me. Now I have
forgotten all the terrifying details and it just works.

I am sure there are other solutions like GSON which I don't have any
experience with.

Furthermore with the upcoming GWT3 which will deprecate generators all
these projects have a scheduled rewrite pending... So who knows?

Vassilis



On Thu, Aug 18, 2016 at 10:33 AM, Max Fromberger <max.fromber...@gmail.com>
wrote:

> Hello everybody,
>
> First of all a big THANKS to everyone involved in developing and
> supporting GWT.
>
> please correct me wherever I am wrong:
>
> In the past you used JsonUtils.safeEval() to create a JavaScriptObject
> from a JSON String. As i understand it, jsinterop annotations on classes
> not extending JavaScriptObject are now preferred over JavaScriptObjects.
>
> What is the recommended, future-proof way of having a server-client common
> class (i.e. package "shared") that can be:
>
> - created and accessed in a JVM servlet
> - created and accessed from the client end
> - serialized to JSON / deserialized from JSON to the specific class on the
> server (e.g. using GSON)
> - serialized to JSON / deserialized from JSON to the specific class on the
> client
>
> Background: Using WebSocket Servers to bidirectionally transfer JSONified
> objects. No GWT-RPC involved.
> Trying to avoid duplicate environment specific classes, boilerplate code
> etc.
>
> Thanks for every clue and please overlook me not having a native English
> interface. ;)
>
>
>
> kind regards,
> max
>
>
> --
> 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+unsubscr...@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+unsubscr...@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.


Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hello everybody,

First of all a big THANKS to everyone involved in developing and supporting 
GWT.

please correct me wherever I am wrong:

In the past you used JsonUtils.safeEval() to create a JavaScriptObject from 
a JSON String. As i understand it, jsinterop annotations on classes not 
extending JavaScriptObject are now preferred over JavaScriptObjects.

What is the recommended, future-proof way of having a server-client common 
class (i.e. package "shared") that can be:

- created and accessed in a JVM servlet
- created and accessed from the client end
- serialized to JSON / deserialized from JSON to the specific class on the 
server (e.g. using GSON)
- serialized to JSON / deserialized from JSON to the specific class on the 
client

Background: Using WebSocket Servers to bidirectionally transfer JSONified 
objects. No GWT-RPC involved.
Trying to avoid duplicate environment specific classes, boilerplate code 
etc.

Thanks for every clue and please overlook me not having a native English 
interface. ;)



kind regards,
max


-- 
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+unsubscr...@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.


[GTW 2.8] How to use JSON-like data with JSInterop

2016-04-22 Thread Hristo Stoyanov
Hi all,
How do I construct input for the following jQuery call:

$('.ui.form') .form({ fields: { name : 'empty', gender : 'empty', username 
: 'empty', password : ['minLength[6]', 'empty'], skills : ['minCount[2]', 
'empty'], terms : 'checked' } }) ;


My current plan is to use JsonUtils/JavaScriptObject in some fashion. Or 
resort to JSNI.

Any better option with JsInterop ?

-- 
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+unsubscr...@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.


Re: Client side format string response to json array and display in jtextetable

2016-04-16 Thread schmitt kevin
 

>
> problem resolved, error is due to bad json, i changed it and work, for 
testing my json array i'm gone https://jsonformatter.curiousconcept.com/ 

> .
>

-- 
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+unsubscr...@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.


Client side format string response to json array and display in jtextetable

2016-04-16 Thread schmitt kevin
Hello everyone, can you help me please?

I try from Client side format string response to json array and display in 
jtextetable.

My class javascript object :

package project.client;

import com . google . gwt. core . client . JavaScriptObject ;
import com . google . gwt. core . client . JsArray ;
class Livre extends JavaScriptObject {
protected Livre () {}

public final native String getTitre () /*-{ return this.Titre; }-*/;
public final native String getAuteurs () /*-{ return this.Auteur;  }-*/;
public final native static JsArray  asArrayOfLivre ( String 
json ) /*-{ return eval ( json );;  }-*/;


}


my response string formated 

res ="[\n";
while (rs.next()) {
String id = rs.getString("id");
String titre = rs.getString("titre");
String auteur = rs.getString("auteur");
res += "\t{Id: \""+id+ "\",\n";
res += "\t{Auteur: \""+titre+ "\",\n";
res += "\t{Titre: \""+auteur+ "\",\n";
res += "\t},\n";
}
res += "]\n";




And in client side : 
  
  public void onSuccess(String result) 
{

JsArray resultat = Livre.asArrayOfLivre ( 
result);

 
for (int i = 0; i < resultat.length(); i++) {
  String Auteur = resultat.get(i).getAuteurs(); 
  String titre =  resultat.get(i).getTitre() ; 
  taskContainer.setText(i+1,0,Auteur);
  taskContainer.setText(i+1,1,titre);
  
}
   
   

 


}
   });



I have no error but if I test one window.alert("test")after  
JsArray resultat = Livre.asArrayOfLivre ( result); it isn't executed 
so function don't executed? do you have idea for my problem?

Thank you.




-- 
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+unsubscr...@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.


Re: How to use json in client side

2016-04-03 Thread schmitt kevin
thanks, finally i used a regex expression with split for get my string in 
client side, and i diplay witht flextable its more easy for me .

-- 
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+unsubscr...@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.


Re: How to use json in client side

2016-04-02 Thread Thomas Broyer


On Saturday, April 2, 2016 at 12:52:51 PM UTC+2, schmitt kevin wrote:
>
> Hello everyone , can you help me please?
>
> in my server wich connect with mysql databse i send to my client one json 
> table like that 
>
> rs = stmt.executeQuery("SELECT * FROM test");
> res ="[";
> while (rs.next()) {
> String titre = rs.getString("id");
> String auteur = rs.getString("comment");
> res += "\t{\"Titre\": \""+titre+ "\",\n";
> res += "\t\"Auteur\": \""+auteur+ "\",\n";
> res += "\t},\n";
> }
> res += "]\n";
>
>
So this returns an array of objects, each object having a Titre and Auteur 
property; e.g.
[{"Titre": "titre 1",
"Auteur": "auteur 1",
},
{"Titre": "titre 2",
"Auteur": "auteur 2",
},
]

Note however that you have dangling commas inside both objects and the 
array, and that's not valid JSON (neither http://json.org nor 
http://www.ecma-international.org/ecma-262/5.1/#sec-15.12.1) so it'll 
likely break at parsing time.

(side note: either use a proper JSON library, or properly escape the titre 
and auteur values or you'll risk corrupting your output)
 

>  and after i try to receive and use json data but dont work 
>
> in my client side 
>
> final ProjectServiceAsync getService = GWT.create(ProjectService.class);
> getService.connection( new AsyncCallback() 
>   {
>public void onFailure(Throwable caught) 
>{
> System.out.println("error");
>}
>
>public void onSuccess(String result) 
>{
> JSONValue jsonValue = JSONParser.parseStrict(result);
> com.google.gwt.json.client.JSONObject customerObject = 
> jsonValue.isObject();
> com.google.gwt.json.client.JSONArray jsonArray = 
> customerObject.get("titre").isArray();
> StringBuilder builder = new StringBuilder("** Livre ** \n"); 
> 
> builder.append(jsonArray.get(0).isObject().get("Titre").isString().stringValue()).append("
>  
> ");
> Window.alert(builder.toString());
>
> //resultTxt.setText(result);
>}
>   });
> }
>
>
This code expects an object at top-level with a Titre property being an 
array of strings; this is not what the sender produces. So even if you fix 
the dangling commas in the JSON produced by the server, this won't work.

Anyway, I suggest using overlay types and JsonUtils.safeEval instead of 
com.google.gwt.json; or even directly go with JsInterop.

final class Livre extends JavaScriptObject {
  protected Livre() {}
  public native String getTitre() /*-{ return this.Titre; }-*/;
  public native String getAuteur() /*-{ return this.Auteur; }-*/;
}
JsArray livres = JsonUtils.safeEval(result);
for (int i = 0, l = livres.length(); i < l; i++) {
  builder.append(livres.get(i).getTitre()).append(" ");
}
 
(side note: similarly to the JSON generation on server-side, if you intend 
to use the 'builder' with toInnerHTML or similar, make sure you properly 
escape it or, better, use SafeHtml, so avoid XSS)

With JsInterop (jsinterop.annotations.*, you'd need 2.8.0-beta1 I believe), 
it'd be something like:
@JsType
interface Livre {
  @JsProperty(name="Titre") String getTitre();
  @JsProperty(name="Auteur") String getAuteur();
}
Livre[] livres = (Livre[]) JsonUtils.safeEval(result);

-- 
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+unsubscr...@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.


How to use json in client side

2016-04-02 Thread schmitt kevin
Hello everyone , can you help me please?

in my server wich connect with mysql databse i send to my client one json 
table like that 

rs = stmt.executeQuery("SELECT * FROM test");
res ="[";
while (rs.next()) {
String titre = rs.getString("id");
String auteur = rs.getString("comment");
res += "\t{\"Titre\": \""+titre+ "\",\n";
res += "\t\"Auteur\": \""+auteur+ "\",\n";
res += "\t},\n";
}
res += "]\n";

 and after i try to receive and use json data but dont work 

in my client side 

final ProjectServiceAsync getService = GWT.create(ProjectService.class);
getService.connection( new AsyncCallback() 
  {
   public void onFailure(Throwable caught) 
   {
System.out.println("error");
   }
   
   public void onSuccess(String result) 
   {
JSONValue jsonValue = JSONParser.parseStrict(result);
com.google.gwt.json.client.JSONObject customerObject = 
jsonValue.isObject();
com.google.gwt.json.client.JSONArray jsonArray = 
customerObject.get("titre").isArray();
StringBuilder builder = new StringBuilder("** Livre ** \n"); 

builder.append(jsonArray.get(0).isObject().get("Titre").isString().stringValue()).append("
 
");
Window.alert(builder.toString());
   
//resultTxt.setText(result);
   }
  });
}

if i use resultTxt.setText(result); i have my data but i want to writte 
table with line received. thanks for you helping sorry for my english

-- 
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+unsubscr...@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.


Re: Any JSON library that works in both GWT and non-GWT environments?

2016-02-05 Thread Thomas Broyer
FWIW, Elemental JSON and AutoBeans work in both environments.
Note that Element JSON is still experimental and will be rewritten at some 
point to take advantage of JsInterop; hopefully it shouldn't impact the API 
much but I can't tell for sure.
AutoBeans' internals will have to be rewritten for GWT 3.0 to replace the 
generator with an annotation processor; it shouldn't impact the API much as 
its much higher-level, except maybe for Splittable. Mayb other libs you'll 
find would be in the same situation I believe, so if you plan on using GWT 
3.0 when it's out (it'll live alongside GWT 2.x for some time), take that 
into account.

IMO, your safest bet is to use JsInterop to represent your data, and handle 
your serialization behind a simple interface that you could implement with 
c.g.g.core.client.JsonUtils on GWT side, and with Jackson or GSON in the 
JVM.
I haven't tried it though, this is just theory.

On Thursday, February 4, 2016 at 11:22:29 PM UTC+1, Matt Campbell wrote:
>
> Hello: 
>
> I want to develop an application that shares code between the browser 
> (via GWT), ANdroid, and iOS (via JJ2ObjC), like Inbox. My application 
> will access JSON-based web APIs, so it needs to be able to parse and 
> serialize JSON. So does anyone know if there's a Java JSON library that 
> works in both GWT and non-GWT environments? I see that GWT has its own 
> JSON package, but that won't work for the other platforms. And a quick 
> look at Gson and Jackson shows that they depend a lot on reflection, 
> which GWT doesn't support. 
>
> Thanks, 
> Matt 
>

-- 
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+unsubscr...@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.


Any JSON library that works in both GWT and non-GWT environments?

2016-02-04 Thread Matt Campbell

Hello:

I want to develop an application that shares code between the browser 
(via GWT), ANdroid, and iOS (via JJ2ObjC), like Inbox. My application 
will access JSON-based web APIs, so it needs to be able to parse and 
serialize JSON. So does anyone know if there's a Java JSON library that 
works in both GWT and non-GWT environments? I see that GWT has its own 
JSON package, but that won't work for the other platforms. And a quick 
look at Gson and Jackson shows that they depend a lot on reflection, 
which GWT doesn't support.


Thanks,
Matt

--
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+unsubscr...@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.


Re: Any JSON library that works in both GWT and non-GWT environments?

2016-02-04 Thread Vassilis Virvilis
I am using Resty-gwt in client side and cxf in server side. I don't' know
about IOS but in theory it should be able to consume valid REST, jax-rs
json.
On Feb 5, 2016 04:50, "Slava Pankov" <pank...@gmail.com> wrote:

> If your server side is going to be implemented on Java, then just use
> Errai JAX-RS (it supports Jackson provider, so can be consumed from any
> client side language).
> That way you have your domain classes in shared folder, and they are used
> both server and client side, so you don't have to serialize/deserialize
> them manually.
>
> If you have something different on the server side, then choose from any
> of the following JSON libs: Piriti and
> https://github.com/hpehl/piriti/wiki/Comparison
>
>
> On Thursday, February 4, 2016 at 2:22:29 PM UTC-8, Matt Campbell wrote:
>>
>> Hello:
>>
>> I want to develop an application that shares code between the browser
>> (via GWT), ANdroid, and iOS (via JJ2ObjC), like Inbox. My application
>> will access JSON-based web APIs, so it needs to be able to parse and
>> serialize JSON. So does anyone know if there's a Java JSON library that
>> works in both GWT and non-GWT environments? I see that GWT has its own
>> JSON package, but that won't work for the other platforms. And a quick
>> look at Gson and Jackson shows that they depend a lot on reflection,
>> which GWT doesn't support.
>>
>> Thanks,
>> Matt
>>
> --
> 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+unsubscr...@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.
>

-- 
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+unsubscr...@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.


Re: Any JSON library that works in both GWT and non-GWT environments?

2016-02-04 Thread Slava Pankov
If your server side is going to be implemented on Java, then just use Errai 
JAX-RS (it supports Jackson provider, so can be consumed from any client 
side language).
That way you have your domain classes in shared folder, and they are used 
both server and client side, so you don't have to serialize/deserialize 
them manually.

If you have something different on the server side, then choose from any of 
the following JSON libs: Piriti 
and https://github.com/hpehl/piriti/wiki/Comparison


On Thursday, February 4, 2016 at 2:22:29 PM UTC-8, Matt Campbell wrote:
>
> Hello: 
>
> I want to develop an application that shares code between the browser 
> (via GWT), ANdroid, and iOS (via JJ2ObjC), like Inbox. My application 
> will access JSON-based web APIs, so it needs to be able to parse and 
> serialize JSON. So does anyone know if there's a Java JSON library that 
> works in both GWT and non-GWT environments? I see that GWT has its own 
> JSON package, but that won't work for the other platforms. And a quick 
> look at Gson and Jackson shows that they depend a lot on reflection, 
> which GWT doesn't support. 
>
> Thanks, 
> Matt 
>

-- 
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+unsubscr...@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.


Re: Guidance on transmitting JSON data

2015-07-07 Thread Gilberto
Well, that question is not only valid for GWT, but for the web in general.

Is REST an option for you? You can use automatic serializers/deserializers 
on the server and on the client for JSON data if you wish.

I recommend restygwt on the client and Jersey (or RestEasy, or Restlet, 
or... insert your framework of choice here) on the server.

Talking about the size of the request or response: gzip is a good option, 
but as a rule of thumb you should try to split the data into smaller 
pieces. Not always possible, but worth a try.

On Monday, July 6, 2015 at 9:07:45 PM UTC-3, rjcarr wrote:

 I have a javascript widget (note, not gwt widget) that takes a javascript 
 object as input.  If I have the JSON representation of this object as a 
 string I can turn it into a javascript object using JSON.parse() and 
 everything works fine.

 However, the data itself will be generated on the server.  From what I can 
 tell, I have two options:

  * Create a GWT-RPC servlet and transfer the json as a string

  * Create a standard servlet, set the response type as application/json, 
 and then write the json as string to the response stream that's retrieved 
 using a request builder

 With both of these cases I'd be gzipping the response.  

 I'm asking because the json response data can get quite large.  Are there 
 any other options I'm missing?  Is there a binary / encoded option other 
 than strings or is the gzipping good enough?

 Generally, are there any best practices for transferring large json data 
 using GWT?

 Thanks!


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


Guidance on transmitting JSON data

2015-07-06 Thread rjcarr
I have a javascript widget (note, not gwt widget) that takes a javascript 
object as input.  If I have the JSON representation of this object as a 
string I can turn it into a javascript object using JSON.parse() and 
everything works fine.

However, the data itself will be generated on the server.  From what I can 
tell, I have two options:

 * Create a GWT-RPC servlet and transfer the json as a string

 * Create a standard servlet, set the response type as application/json, 
and then write the json as string to the response stream that's retrieved 
using a request builder

With both of these cases I'd be gzipping the response.  

I'm asking because the json response data can get quite large.  Are there 
any other options I'm missing?  Is there a binary / encoded option other 
than strings or is the gzipping good enough?

Generally, are there any best practices for transferring large json data 
using GWT?

Thanks!

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


Re: How to load a json file on client side without clientbundle?

2015-03-20 Thread Marc-Andre Bruneau
Hi,

The solution I use is with a RequestBuilder.

String url = FULLPATH + yourfile.json;
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

try {
  builder.sendRequest(null, new RequestCallback() {

@Override
public void onError(Request request, Throwable exception) {
  // ...
}

@Override
public void onResponseReceived(Request request, Response response) {
  // ... some validation
  JSONValue jsonConfig = JSONParser.parseStrict(response.getText());
  // ...
}
  }
} catch (RequestException e) {}

Hope this helps.

On Thursday, March 19, 2015 at 12:06:29 PM UTC-7, Dr.Doom wrote:

 Hi,

 I need an offline solution for my gwt project and i thought i can just put 
 the data as json files as resources in my project.

 Is there a way to load this json files on the client side?
 i only found the way with clientbundle, but then i cant modify the json 
 data files without recompiling the project.





 Thx for the answers ;)


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


Re: How to load a json file on client side without clientbundle?

2015-03-20 Thread Thad Humphries
Solutions depend on when you want load the JSON files and who loads them. 
If the user is to pick the file, use the FileUpload widget to load the file 
to the server, then send it right back to your client (maybe after some 
server side safety checking). If the JSON files are restricted to an 
administrator, you could control the file upload by your application's 
authentication scheme. Alternately, you could define the JSON file (or 
files) in the application's servlet context (with Tomcat, 
META-INF/context.xml in your WAR). When the app deploys, the administrator 
would edit $CATALINA_BASE/conf/Catalina/[hostname]/[appname].xml to give 
the file's full path.

On Thursday, March 19, 2015 at 3:06:29 PM UTC-4, Dr.Doom wrote:

 Hi,

 I need an offline solution for my gwt project and i thought i can just put 
 the data as json files as resources in my project.

 Is there a way to load this json files on the client side?
 i only found the way with clientbundle, but then i cant modify the json 
 data files without recompiling the project.





 Thx for the answers ;)


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


How to load a json file on client side without clientbundle?

2015-03-19 Thread Dr.Doom
Hi,

I need an offline solution for my gwt project and i thought i can just put 
the data as json files as resources in my project.

Is there a way to load this json files on the client side?
i only found the way with clientbundle, but then i cant modify the json 
data files without recompiling the project.





Thx for the answers ;)

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


Which Json/JSON package I have to use?

2015-03-05 Thread Alex Ph
Hi all,
I want to upgrade from 2.6.1 to 2.7.0 and I use autobeans to handle JSON 
data. Due to json-issues (like 
https://code.google.com/p/google-web-toolkit/issues/detail?id=8762) you 
moved/removed the org.json package and I have to reorg my imports. 

I have three options to replace my old org.json.JSONObject import and I 
wonder which import I have to choose:

1) com.google.gwt.thirdparty.json.JSONObject (used by Autobean)
2) com.google.gwt.json.client.JSONObject
3) com.google.gwt.dev.json.JsonObject

Any Hints here?

Thanks
Alex

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


Re: Which Json/JSON package I have to use?

2015-03-05 Thread Alex Ph
Hi,
thnx for the fast response :)

Am Donnerstag, 5. März 2015 11:26:07 UTC+1 schrieb Thomas Broyer:



 On Thursday, March 5, 2015 at 10:32:55 AM UTC+1, Alex Ph wrote:

 Hi all,
 I want to upgrade from 2.6.1 to 2.7.0 and I use autobeans to handle JSON 
 data. Due to json-issues (like 
 https://code.google.com/p/google-web-toolkit/issues/detail?id=8762) you 
 moved/removed the org.json package and I have to reorg my imports. 

 I have three options to replace my old org.json.JSONObject import and I 
 wonder which import I have to choose:


 If you use AutoBeans, why do you need org.json?

Because I was blind and I didn't see that we only use json.org stuff in our 
test cases to load test.json files

 Anyway, if you need org.json, add it as a dependency (download the JAR, or 
 add the dependency to your pom.xml or build.gradle or ivy.xml or whatever 
 you're using) and use it (and comply with its license).

I think I should have a look at the json licence :)

Thnx for your explanation of the three type of JsonObjects

Best regards
Alex 

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


Re: Which Json/JSON package I have to use?

2015-03-05 Thread Thomas Broyer


On Thursday, March 5, 2015 at 10:32:55 AM UTC+1, Alex Ph wrote:

 Hi all,
 I want to upgrade from 2.6.1 to 2.7.0 and I use autobeans to handle JSON 
 data. Due to json-issues (like 
 https://code.google.com/p/google-web-toolkit/issues/detail?id=8762) you 
 moved/removed the org.json package and I have to reorg my imports. 

 I have three options to replace my old org.json.JSONObject import and I 
 wonder which import I have to choose:


If you use AutoBeans, why do you need org.json?
Anyway, if you need org.json, add it as a dependency (download the JAR, or 
add the dependency to your pom.xml or build.gradle or ivy.xml or whatever 
you're using) and use it (and comply with its license).

1) com.google.gwt.thirdparty.json.JSONObject (used by Autobean)


Anything in c.g.g.thirdparty can change without notice between GWT 
versions, so it could very well disappear in the next version of GWT.
 

 2) com.google.gwt.json.client.JSONObject


This is only usable in client-side code; won't work where you used to use 
org.json.
 

 3) com.google.gwt.dev.json.JsonObject


Isn't in gwt-servlet.jar AFAIK, so won't be available at runtime.
 

 Any Hints here?


There's also elemental.json but it's still experimental.

No, really, if you're happy with org.json, then just continue using it; all 
you have to do is add it to your classpath.

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


Re: JSON JsDate/Date encode/decode with restyGWT

2015-02-04 Thread Juan Calderón
Thanks,

The mapping java.util.Date  JSON is automatic; so, I was wrong because 
JsDate is not necessary :)

Le lundi 26 janvier 2015 12:14:11 UTC-7, Jens a écrit :

 Probably better asked on a restyGWT forum or on their Github issue tracker.

 But I guess you have to use java.util.Date on client and server or you 
 have to extend restyGWT so it knows how to map JsDate - Date.

 -- J.


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


Re: JSON JsDate/Date encode/decode with restyGWT

2015-01-26 Thread Jens
Probably better asked on a restyGWT forum or on their Github issue tracker.

But I guess you have to use java.util.Date on client and server or you have 
to extend restyGWT so it knows how to map JsDate - Date.

-- J.

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


JSON JsDate/Date encode/decode with restyGWT

2015-01-26 Thread Juan Calderón


Rookie question from a non-English speaker:

I’m using restyGWT.  Client side with a Pojo Model and Server side with the 
corresponding JPA Entity class.

For decode/encode between both:

public interface EmpleadoJsonCodec extends JsonEncoderDecoderEmpleado {}

public EmpleadoJsonCodec empleadoListJsonCodec = 
GWT.create(EmpleadoJsonCodec.class);

….

public void onSuccess(Method method, JSONValue response) {

Empleado empleado = empleadoListJsonCodec.decode(response);

….

 

Everything was working perfect (GETs, PUTs, etc.) until I tried to add a 
JsDate/Date field to the Model/Entity.

I don´t know how to use JsDate/Date. What should I put in the Model (or 
Entity) so the Json (JSONValue responde) decode works fine?

Thanks,

 

Juan

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


Problem retrieving JSON data from a server using http get request

2014-08-11 Thread Nikhil
I am running a gwt application with the host page hosted on a tom cat 
server. By default the domain name (i.e. document.domain) of the host html 
is mysystem.systemgroup.example.com:12345. I tried to retrieve JSON data 
from a server hosted at myserver.systemgroup.example.com:12345. The GET 
request failed with error net::ERR_CONNECTION_REFUSED (in chrome).

Then I changed the document domain to example.com using document.write() 
script and I am still getting the same error.

How do I avoid this issue? Both client and server are running in the same 
domain i.e. example.com.

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


Re: Problem retrieving JSON data from a server using http get request

2014-08-11 Thread Cloud
can u dont use the port number 12345. make it default 80.
On Aug 11, 2014 8:25 PM, Nikhil nikhil.ana...@gmail.com wrote:

 I am running a gwt application with the host page hosted on a tom cat
 server. By default the domain name (i.e. document.domain) of the host html
 is mysystem.systemgroup.example.com:12345. I tried to retrieve JSON data
 from a server hosted at myserver.systemgroup.example.com:12345. The GET
 request failed with error net::ERR_CONNECTION_REFUSED (in chrome).

 Then I changed the document domain to example.com using
 document.write() script and I am still getting the same error.

 How do I avoid this issue? Both client and server are running in the same
 domain i.e. example.com.

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


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


Re: Problem retrieving JSON data from a server using http get request

2014-08-11 Thread Jens
What you are doing is violating the same origin policy for ajax requests: 
http://en.wikipedia.org/wiki/Same-origin_policy

You can use JSONP or CORS to fetch data from a domain other than your host 
page (other domains includes sub domains). Otherwise you need to proxy 
requests from mysystem to myserver using reverse proxy features of your web 
server.

-- J.

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


Re: [gwt-contrib] Discussion: Elemental Json

2014-08-06 Thread Manuel Carrasco Moñino
On Sat, Aug 2, 2014 at 2:55 AM, 'Ray Cromwell' via GWT Contributors 
google-web-toolkit-contributors@googlegroups.com wrote:

 It is likely that all of the non-collections stuff is going to be
 totally redone with JsInterop.
 The actual collections interfaces (ArrayOf, etc) as well as Json, we
 may keep because it is useful to to have JRE implementations to work
 in a shared context.


Sounds well, so we can trust that they will remain in Elemental, and the
API should be similar, right?



 However, the implementations backing those are likely to be completely
 rewritten to use JsInterop. I don't mind splitting things up in
 elemental if they want.  My gut feeling is that Elemental 2.0 may have
 a completely different package structure.


Any plans for Elemental 2.0? Someone working on it?

In the meanwhile, I've done a couple of fixes so as tests can be run in
builds, next will be a patch for passing Json and Collections tests in JRE,
sounds it reasonable for you? could you take a look in gerrit?






 On Fri, Aug 1, 2014 at 8:07 AM, Manuel Carrasco Moñino
 man...@apache.org wrote:
 
  Hi all
 
  There is a patch [1] from Thomas in gerrit for spliting elemental
 apparently
  in 3 libraries:
  - elemental-collections
  - elemental-json
  - elemental
 
  1.- What are the plans with elemental-json and elemental-collections?
  2.- Are they though to replace some similar stuff in gwt-user like
  JsonUtils?
  3.- Could it replace Json code in server side depending org.json?
  4.- Is someone working on spliting the code?
 
 
  Thanks
  - Manolo
 
  [1] https://gwt-review.googlesource.com/#/c/4210/
 
  --
  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/CAM28XAtc9z3nbmrfz0Ev%3D3SSFk%3DPZJY%2BBtk_03xOgiVwReHTrQ%40mail.gmail.com
 .
  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/CAPVRV7dvDF1SLoeJzGSidOmuQizEY5TvNfMvf_gPxenA_YYE%3DA%40mail.gmail.com
 .
 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/CAM28XAsRWyL4Ve7gOykHGWO0iu9NrMwnxb%3DiK9g%2BypgAaxHSWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gwt-contrib] Discussion: Elemental Json

2014-08-01 Thread Manuel Carrasco Moñino
Hi all

There is a patch [1] from Thomas in gerrit for spliting elemental
apparently in 3 libraries:
- elemental-collections
- elemental-json
- elemental

1.- What are the plans with elemental-json and elemental-collections?
2.- Are they though to replace some similar stuff in gwt-user like
JsonUtils?
3.- Could it replace Json code in server side depending org.json?
4.- Is someone working on spliting the code?


Thanks
- Manolo

[1] https://gwt-review.googlesource.com/#/c/4210/

-- 
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/CAM28XAtc9z3nbmrfz0Ev%3D3SSFk%3DPZJY%2BBtk_03xOgiVwReHTrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Discussion: Elemental Json

2014-08-01 Thread 'Goktug Gokdogan' via GWT Contributors
(Responded for the parts that I know the answer for)


On Fri, Aug 1, 2014 at 8:07 AM, Manuel Carrasco Moñino man...@apache.org
wrote:


 Hi all

 There is a patch [1] from Thomas in gerrit for spliting elemental
 apparently in 3 libraries:
 - elemental-collections
 - elemental-json
 - elemental

 1.- What are the plans with elemental-json and elemental-collections?


We are probably re-think everything with Elemental 2.0.


 2.- Are they though to replace some similar stuff in gwt-user like
 JsonUtils?
 3.- Could it replace Json code in server side depending org.json?
 4.- Is someone working on spliting the code?


Not on our side.




 Thanks
 - Manolo

 [1] https://gwt-review.googlesource.com/#/c/4210/

  --
 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/CAM28XAtc9z3nbmrfz0Ev%3D3SSFk%3DPZJY%2BBtk_03xOgiVwReHTrQ%40mail.gmail.com
 https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAM28XAtc9z3nbmrfz0Ev%3D3SSFk%3DPZJY%2BBtk_03xOgiVwReHTrQ%40mail.gmail.com?utm_medium=emailutm_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%3DyUA3s2KH65-8c%3Db23yR3nnDNvLRyyx_QAndtprBphJ%3DgCSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gwt-contrib] Discussion: Elemental Json

2014-08-01 Thread 'Ray Cromwell' via GWT Contributors
It is likely that all of the non-collections stuff is going to be
totally redone with JsInterop.
The actual collections interfaces (ArrayOf, etc) as well as Json, we
may keep because it is useful to to have JRE implementations to work
in a shared context.

However, the implementations backing those are likely to be completely
rewritten to use JsInterop. I don't mind splitting things up in
elemental if they want.  My gut feeling is that Elemental 2.0 may have
a completely different package structure.



On Fri, Aug 1, 2014 at 8:07 AM, Manuel Carrasco Moñino
man...@apache.org wrote:

 Hi all

 There is a patch [1] from Thomas in gerrit for spliting elemental apparently
 in 3 libraries:
 - elemental-collections
 - elemental-json
 - elemental

 1.- What are the plans with elemental-json and elemental-collections?
 2.- Are they though to replace some similar stuff in gwt-user like
 JsonUtils?
 3.- Could it replace Json code in server side depending org.json?
 4.- Is someone working on spliting the code?


 Thanks
 - Manolo

 [1] https://gwt-review.googlesource.com/#/c/4210/

 --
 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/CAM28XAtc9z3nbmrfz0Ev%3D3SSFk%3DPZJY%2BBtk_03xOgiVwReHTrQ%40mail.gmail.com.
 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/CAPVRV7dvDF1SLoeJzGSidOmuQizEY5TvNfMvf_gPxenA_YYE%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


build new editor framework driver to add JSON support feature to editor framework

2014-07-13 Thread saman sheikhtajian


my GWT application work with JSON instead of POJO,I want to bind my forms to 
JSON Objects and vise versa, is it possible add this feature to Editor 
framework ?

How can I extends EditorDriver  build new driver  some thing like 
SimpleJsonEditorDriver ?


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


JSON to ValueProxy

2014-07-10 Thread trayan . simeonov
Is there some way using AutonBean.decode to convert standart json - {name 
: Some name} to 

class NameProxy extends ValueProxy{
  String getName();

 void setName(String name);
}

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


Re: JSON to ValueProxy

2014-07-10 Thread Vasu
If you are looking to generate OverlayTypes. I have created one maven 
plugin which can generate OverlayType but it will generate it from Server 
side Java Bean class and not from Json. You have to add few annotation and 
this plugin will do the job. refer following 
project https://github.com/pandurangpatil/gwt-mvn-helper. You will find a 
sample inside mvn-helper-test module. This plugin is more helpful if you 
are using Request Factory.


[image: Pandurang Patil on about.me] 
Pandurang Patil
about.me/pandurangpatil
  http://about.me/pandurangpatil
website: http://www.agnie.net
twitter: @agniesoftware
Cell : +91-9823241535

On Thursday, 10 July 2014 15:04:03 UTC+5:30, trayan@agilemates.com 
wrote:

 Is there some way using AutonBean.decode to convert standart json - 
 {name : Some name} to 

 class NameProxy extends ValueProxy{
   String getName();

  void setName(String name);
 }


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


Re: Connecting a DataGrid to a JSON source

2014-06-02 Thread Ed
I would look in the GXT code for examples and inspiration. They have a lot 
of these constructions like you want.

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


Connecting a DataGrid to a JSON source

2014-05-31 Thread Patrick May
I'm looking through the examples and tutorials for DataGrid and, frankly, 
it's a mess.  I want to display JSON data that is being updated from the 
server.  The whole TextColumn mechanism is a lot of overhead that is 
difficult to abstract away.

Is there any alternative that provides similar functionality but is easier 
to use and that integrates well with the rest of GWT?

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


Invalid JSON Response - How do I Parse This Data Correctly Then?

2014-03-20 Thread Fionn Ball
Considering Firebug tells me the response is:

{id: 3, result: {FE0CBC0: {Channel063: 128, Channel215: 128

service_.getValues( cbcNames , new AsyncCallbackString[]() {

   public void onSuccess(String[] result) //Also tried Map String, String 
String, String [] - these acted in the same way (things like Object crashed 
the entire object), String [] [] resulted in no sending/receiving of data

 {

  echo_.setText(result);

  }

public void onFailure(Throwable caught)

 {

  caught.printStackTrace();

try {

throw caught;

  } catch (IncompatibleRemoteServiceException error) {

   

  echo_.setText( Client not compatible with server, cleanup browser 
and refresh ( + error.getMessage() + ));

  } catch (InvocationException error) {

   

  echo_.setText( Call didn't complete cleanly ( + error.getMessage() 
+ ));

  } 

catch (Throwable error) {

 

  echo_.setText( Unexpected server error! ( + error.getMessage() + )
);

  }


It always says Invalid JSON Response.

Yet if I change it from String [] to JSONObject, it goes into onSuccess 
with NO DATA:


service_.getValues( Names , new AsyncCallbackJSONObject() {

public void onSuccess(JSONObject result) 
{   
 if (result.containsKey(result) == true){
 echo_.setText(result);
 }

 else { echo_.setText(no result);}
}

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


Re: JSON+RequestBuilder vs RequestFactory

2013-11-03 Thread m1kema
Not sure if my first question went in ... Checking to see, if you were able 
to come up with a resolution to your question ?

We have an existing Spring MVC backend, that we would like to hook up to an 
GWT front-end.  Have similar questions/issues in terms of how
we would like to communicate with backend (e.g., RequestBuilder, 
RequestFactory, etc) and if it is possible for GWT and Spring MVC to 
co-exist.

Thanks,
Mike

On Wednesday, November 17, 2010 1:59:55 AM UTC-6, zixzigma wrote:

 Hello everyone. 

 What are the benefits of using RequestFactory over JSON/Request 
 Builder. 

 to implement client-side communication/persistence i have to options: 

 1- using Spring/Spring MVC on the server to handle all the server-side 
 work, 
 and send JSON data to the GWT client. 

 2- i believe I still can use SpringMVC with RequestFactory, though not 
 as cleanly seperated as the first approach. 

 all the code will be in Java. 

 What are the benefits of using RequestFactory over JSON/ 
 RequestBuilder ? 


 Thank You

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


Re: JSON+RequestBuilder vs RequestFactory

2013-11-03 Thread m1kema
Hello zixzigma,

Did you ever come up with a resolution here ?

I'm new to GWT, and we currently have a Spring MVC backend, that we would 
like to communicate with. 

Were you able to integrate which such a backend ?   if so, which option(s) 
did you go with, and do you have any example of such ?

Thanks for any help that you may be able to provide.

- Mike

On Wednesday, November 17, 2010 1:59:55 AM UTC-6, zixzigma wrote:

 Hello everyone. 

 What are the benefits of using RequestFactory over JSON/Request 
 Builder. 

 to implement client-side communication/persistence i have to options: 

 1- using Spring/Spring MVC on the server to handle all the server-side 
 work, 
 and send JSON data to the GWT client. 

 2- i believe I still can use SpringMVC with RequestFactory, though not 
 as cleanly seperated as the first approach. 

 all the code will be in Java. 

 What are the benefits of using RequestFactory over JSON/ 
 RequestBuilder ? 


 Thank You

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


autobean structure for a complex JSON

2013-09-23 Thread aditi
In autobeans, while decoding a complex json object , so we have to create 
an interface for every property in json object that has { } ??
If yes, then are we not creating large number of autobean interfaces even 
to fetch a simple json property value? Or is there a way to have a better 
hierarchy or autobean?

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


JSON discrepancy in gwt-dev.jar vs. json-20090211.jar

2013-09-20 Thread Thad Humphries
I spent much of yesterday moving an old GWT project from Ant to Maven. Much 
of that time was spent running down a serious discrepancy in the 
server-side conversion of XML to JSON, specifically the call 
org.json.XML*.*toJSONObject(java.lang.String 
string). (I'm thinking this needs to be filed as an issue.)

The project was originally built with Ant. Following the build.xml in the 
GWT samples, it had gwt-dev.jar in the project classpath (see, for example, 
Showcase's build.xml). When run in devmode, this version of JSON will 
convert

width448/width
height293/height

to 

{height:293, width:448}

When this arrives at the client-side, in terms of the 
com.google.gwt.json.client package we have a JSONString vs. a JSONNumber.

In my Maven build, the pom.xml declares dependencies only on 
gwt-servlet.jar and gwt-user.jar, neither of which includes org.json 
(though gwt-servlet-deps.jar has the same org.json as gwt-dev.jar). JSON is 
being provided by json-20090211.jar from mavenrepository.com. Now that same 
XML converts to

{height:293, width:448}

JSONNumber vs JSONString! This makes a *huge* difference in how the data is 
handled:

   JSONString: int width = Integer.parseInt(jsonObject.get(width
).isString().stringValue());

   JSONNumber: int width = (int)jsonObject.get(width
).isNumber().doubleValue();

Use the wrong one and an exception is thrown.
I think that json-20090211.jar is the correct approach. Certainly AutoBean 
would fail if it got a string vs a number for an integer field (or maybe 
just a zero value?).

One can get the same results with the Ant in devmode by removing fileset 
dir=${gwt.sdk} includes=gwt-dev*.jar/ from project.class.path and 
adding it only to the gwtc and devmode targets (and any target using 
GWTTestCase). However I think that GWT should be brought in line with 
json-20090211.jar. (Looking at the tools directory for building GWT, it 
seems the JSON used (r2_20080312) is not a version available from 
mavenrepository.com.)

Has anyone else seen this? I don't see an issue filed on it. I'm happy to 
put one in, but I thought I'd raise it here first.


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


JSON object to AutoBean via JSNI in DevMode

2013-08-27 Thread Jens
Hi,

is there anything faster than

final String payload = new JSONObject(jsonDataFromJSNI).toString();
dataBean = AutoBeanCodex.decode(factory, Data.class, payload);

when in DevMode? The JSON data is embedded into the host page and not that 
tiny (worst case ~600kb uncompressed) and the above solution makes DevMode 
hang for about 3-5 seconds when refreshing the site. Thats kind of annoying 
and I just want to make sure I didn't miss a different solution for DevMode 
thats maybe faster.

-- J.

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


  1   2   3   4   5   6   7   8   >