Search code examples
jsongwtjacksongsonvaadin7

Is elemental json is not compatible with google gson?


My application's vaadin version is upgraded from 7.3.6 to 7.4.6 and my Json code wherever I was using the GSON is starting to break.

I did googling for the same I found the similar issue mentioned in this stackOverflowPost

So should I conclude that elemental.json is not compatible with GSON and org.json was compatible with GSON.


Solution

  • GSON is not GWT compatible, which makes sense since it requires reflection to do its work. Likewise, org.json is meant to be used on a normal JVM.

    On the other hand, GWT knows it is running in the browser, so doesn't need to implement its own JSON parser, since the browser already has one. There are several ways to use JSON in GWT, and GSON, org.json, and the built-in JSON parser of the browser all speak the same JSON.

    All are compatible with each other, though you can't simply use elemental on the server or GSON on the client, or reuse the same server types on the client.

    What specifically is 'starting to break'? What errors do you get, and what does the data that you are trying to send look like?

    (Also worth noting, some of the 'json' in the linked post uses ' quotes for properties and strings, which is not legal JSON and should not work in the first place with any proper JSON parser.)