FlexJson deserialization with custom ObjectFactories

不问归期 提交于 2019-12-10 11:39:18

问题


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!

来源:https://stackoverflow.com/questions/7792156/flexjson-deserialization-with-custom-objectfactories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!