Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json转换成对应的对象,如果是父类,希望根据规则转化成子类 #2289

Closed
z466459262 opened this issue Feb 18, 2019 · 4 comments
Milestone

Comments

@z466459262
Copy link

z466459262 commented Feb 18, 2019

我想根据btype 把json转换成对应的对象,有可能类的层次有点深,目前没有对应的api,目前我都是把json手动转的,很麻烦。

public class A {
    List<B>  bList;

    String bType;
}

interface B{

}
class B1 implements B{
    String a;
}
class B2 implements B{
    Integer bb;
}

已经内部咨询了温少,说会支持,谢谢哈

@wenshao wenshao added this to the 1.2.57 milestone Apr 11, 2019
wenshao added a commit that referenced this issue Apr 11, 2019
@wenshao
Copy link
Member

wenshao commented Apr 11, 2019

https://github.com/alibaba/fastjson/releases/tag/1.2.57
问题已修复,请用新版本

@wenshao wenshao closed this as completed Apr 11, 2019
@mominet
Copy link

mominet commented Dec 5, 2019

并没有解决啊。这个需求要求转换成子类,而https://github.com/alibaba/fastjson/wiki/WriteAs_CN讲的是转换成父类。

@mominet
Copy link

mominet commented Dec 5, 2019

另外,这个需求讲的是反序列化,而 https://github.com/alibaba/fastjson/wiki/WriteAs_CN 讲的则是序列化。完全不是一回事啊。

@mominet
Copy link

mominet commented Dec 5, 2019

我发现Jackson支持这个,现在换成Jackson了。
https://my.oschina.net/u/3664884/blog/1932829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants