问题标签 [autobean]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
611 浏览

java - 如何在 GWT 中使用 autobean 将 json 转换为 java 类

我有一个类Persongwt我已经发送了一个使用从服务器到客户端Person转换的 servlet实例。Gson但在客户端似乎我无法使用Gson. 从我在论坛上读到的内容看来,最好的方法是使用再次AutoBeans转换Json为对象Person

但是在AutoBeans我只能使用一个界面。如果有人可以帮我写它,我将不胜感激。

json我从服务器获得并想Person再次转换为类的示例:

{"name":"aaa","family":"fff","username":"uuu","age":20,"phones":[{"id":0,"phoneNumber":"0911111" }],"亲戚":[null]}

0 投票
1 回答
14 浏览

serialization - gwt autobean 的多个编码器导致 AssertionError

从 JSON 反序列化 autobean 时,我得到一个AssertionErrorfrom com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.CoderCreator#getCoder。看起来我的 autobeans 注册了两种类型:

  • my.project.model.MyAutoBean
  • java.lang.类

当然,我发现第二个非常没用,但我不知道它来自哪里以及如何摆脱它。当我禁用断言时,代码可以正常工作并完美地(反)序列化我的 Autobean。

我已经在初始化中获得了两种类型,ClientPropertyContext但我无法调试MyAutoBean.traverseProperties正在发生的事情。