I have the following class that has to be serialized:
@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;
}
Since it contains BigDecimal fields, I added the annotation
@JsonFormat(shape=JsonFormat.Shape.STRING)
Unfortunately, it doesn't work and I still get the error:
###UncheckedExecutionException: com.fasterxml.jackson.databind.JsonMappingException: N/A at [Source: (byte[])"{"campaignIdToFactorComputationData":{"1032633420":{"pacingFactor":0.001,"pidError":-0.6111111111111112,"pidIntegral":0.001,"selectedCountryCode":"IL","targetCappingHourExcluded":18,"startingHourIncluded":0,"selectedMarketHistoryDataForCampaign":{"countryCode":"IL","hourToExpectedEngagePaidListings":{"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"[truncated 528 bytes]; line: 1, column: 934] (through reference chain: ###BudgetPacerCycleOutput["campaignIdToCurrentData"]->java.util.LinkedHashMap["1032633420"]->###.CampaignCurrentData["amountSpent"])
I tried to replace the annotations
@JsonFormat(shape=JsonFormat.Shape.STRING)
with
@JsonIgnore
and I didn't get the error. However, I don't want to ignore these fields. What can I do?