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 <[email protected] > <javascript:>> 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 [email protected] >> <javascript:>. >> 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&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. 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.
