在 GWT 应用程序中使用 codehaus 'ObjectMappper' class 解析 json
Using codehaus 'ObjectMappper' class in GWT application to parse json
我想在 GWT 应用程序的客户端使用 'codehaus' 库中的 ObjectMapper
class。我收到错误 no source code available for ObjectMapper class
.
有什么解决办法吗?无法在 GWT 应用程序中使用 Java 库 classes 吗?
可以在 GWT 中使用 Java 源代码,但应修改库。一些库只需要一个 GWT module 来指示源代码应该由 GWT 转译,而其他库可能需要某种程度的改编。具体来说,GWT不支持任何与反射有关的东西,Jackson大量使用反射,适应起来比较困难。
解决方案:您应该使用替代实现,例如https://github.com/nmorel/gwt-jackson or https://github.com/DominoKit/gwt-jackson-apt. Or just delegate the coding/decoding of JSON to the native JSON optionally applying the JsInterop DTO strategy,使模型在 GWT 客户端和 JRE 服务器端都能工作。
我想在 GWT 应用程序的客户端使用 'codehaus' 库中的 ObjectMapper
class。我收到错误 no source code available for ObjectMapper class
.
有什么解决办法吗?无法在 GWT 应用程序中使用 Java 库 classes 吗?
可以在 GWT 中使用 Java 源代码,但应修改库。一些库只需要一个 GWT module 来指示源代码应该由 GWT 转译,而其他库可能需要某种程度的改编。具体来说,GWT不支持任何与反射有关的东西,Jackson大量使用反射,适应起来比较困难。
解决方案:您应该使用替代实现,例如https://github.com/nmorel/gwt-jackson or https://github.com/DominoKit/gwt-jackson-apt. Or just delegate the coding/decoding of JSON to the native JSON optionally applying the JsInterop DTO strategy,使模型在 GWT 客户端和 JRE 服务器端都能工作。