fastjson SupportArrayToBean切换

iecba09b  于 2021-11-27  发布在  Java
关注(0)|答案(2)|浏览(280)

有这样的一个json文件,
定义了Bean是:

public class SyncFileResponse{
private SyncFileResponseContent content;
...
}

 @JSONType(serialzeFeatures= SerializerFeature.BeanToArray, parseFeatures= Feature.SupportArrayToBean)
public class SyncFileResponseContent{
    private List<FileModel> fileModel;
    private List<LibCategoryBean> categoryModel;
    private LibrarySyncStatusBean syncStatusBean;
    private List<GroupRelateFileBean> groupRelateFileBeen;
    private List<LibTagBean> tagBeen;
    private List<LibTagRelatedBean> tagRelatedBeen;
....
}

SyncFileResponse model = JSON.parseObject(jsonString, SyncFileResponse.class, Feature.SupportArrayToBean);

报错

问题是否在于 LibCategoryBean 也采用了SupportArrayToBean的解析方式,是否可以定制下LibCategoryBean采用默认的解析方式

ocebsuys

ocebsuys1#

你是希望全部BeanToArray还是局部采用?

6ojccjat

6ojccjat2#

@wenshao

SupportArrayToBean 部分采用

相关问题