jackson:为什么用@jsonformat(shape=jsonformat.shape.string)注解bigdecimal字段不起作用?

xwmevbvl  于 2021-07-07  发布在  Java
关注(0)|答案(0)|浏览(824)

我有以下必须序列化的类:

@JsonIgnoreProperties(ignoreUnknown = true)
public class CampaignCurrentData {
    private static final int FRAC_SPENT_SCALE = 6;

    //TBD: transfer campaign ID to long in proto and here
    private Long campaignId;
    private Long budgetId;
    @JsonFormat(shape=JsonFormat.Shape.STRING)
    private BigDecimal amountSpent;
    @JsonFormat(shape=JsonFormat.Shape.STRING)
    private BigDecimal dailyBudget;
    @JsonFormat(shape=JsonFormat.Shape.STRING)
    private BigDecimal fracSpent;
    private Set<String> countriesSet;
    private boolean isCampaignCbs;
}

因为它包含bigdecimal字段,所以我添加了注解

@JsonFormat(shape=JsonFormat.Shape.STRING)

不幸的是,它不工作,我仍然得到错误:

取消选中dexecutionexception:com.fasterxml.jackson.databind.jsonmappingexception:n/a at[source:(byte[])“{”campaignidtofactorcomputiondata“:{”1032633420“:{”pacingfactor“:0.001,”piderro“:-0.611111112,”pidiintegral“:0.001,”selectedcountrycode“:”il“,”targetcappinghourexcluded“:18,”startinghoulincluded“:0,“selectedmarkethistorydataforcampaign”:{“countrycode”:“il”,“HourtExpectedEngagePaidListings”:{“1 0”:10.0,“0 0”:10.0,“23 0”:10.0,“22 0”:10.0,“21 0”:10.0,“20 0”:10.0,“19 0”:10.0,“18 0”:10.0,“17 0”:10.0,“16 0”:10.0,“15 0”:10.0,“14 0”:10.0,“13 0”:10.0,“12 0”:10.0,“11 0”:10.0,“10 0”:10.0,“9 0”:10“[528字节];行:1,列:934](通过引用链:###budgetpacercycleoutput[“campaignidtocurrentdata”]->java.util.linkedhashmap[“1032633420”]->###.campaigncurrentdata[“AmountSpend”])

我试着替换注解
@jsonformat(shape=jsonformat.shape.string)
具有
@杰索尼诺
但我没有发现错误。但是,我不想忽略这些字段。我能做什么?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题