Thursday, September 21, 2017

Re: elemental.json confusion/error

If you need to parse JSON with a known structure, use JsInterop to describe that structure (as @JsType(isNative=true, namespace=JsPackage.GLOBAL, name="*"), or name="Object" if you can't use name="*"), and then either<JavaScriptObject>safeEval() with a cast to your JsInterop interface/class, or JsInterop to call JSON.parse() (as @JsMethod(namespace="JSON", name="parse") static native <T> T parseJson(String json)).
If you don't know the structure upfront, then use jsinterop-base's types instead (JsPropertyMap mostly, and the Js helper class), and the same method for parsing. You might also want to have a look at elemental2-core: (which BTW defines JSONType.parse(…)), but be careful as Elemental2 is entirely generated, and might change in the future as the generator evolves (also, Elemental 2 might require that you use the HEAD-SNAPSHOT of GWT)
Thanks for that. I'll look into those solutions. 
These are likely bugs, and they're unlikely to ever be fixed (unless maybe someone provides the patch).

Would do that, but I don't know how those work :/
The correct way is Json.instance(), one shouldn't ever use any "impl" class.

That's totally correct. Didn't see it :) 

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
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment