使用自定义 ObjectFactories 进行 FlexJson 反序列化
我正在使用 FlexJson 通过 JSON 支持我的实体。
但我在反序列化它们时确实遇到了一些问题,因为我想要一个“短数据量”来减少后端和客户端之间发送的数据量。
让我们建议我们确实有一个引用地址的 Person 类:
public class Person {
private String firstname;
private String surname;
private Address address;
}
所以我现在想要的是,反序列化仅包含地址 id 的 Person 对象,并通过此 id 从数据库加载地址。
{
"firstname":"Michael",
"surname":"Blomkvist",
"addressid":"1"
}
有什么建议如何告诉 JSONDeserializer 吗?
我尝试添加 use("addressid", new MyCustomAddressObjectFactory()) 但它永远不会被调用。
我将不胜感激任何帮助!
提前致谢!
I am using FlexJson to support my entities with JSON.
But I do have some problems deserializing them, because I want a "short data amount" to reduce the data volume sent between backend and client.
Lets suggest we do have a Person class which references to an address:
public class Person {
private String firstname;
private String surname;
private Address address;
}
So what I now want is, to deserialize an Person object containing just the address id and loading the address via this id from the database.
{
"firstname":"Michael",
"surname":"Blomkvist",
"addressid":"1"
}
Any suggestions how to tell this the JSONDeserializer?
I tried to add a use("addressid", new MyCustomAddressObjectFactory()) but it never gets called.
I would appreciate any help!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论