title: Jackson: why doesn't annotating BigDecimal fields with @JsonFormat(shape=JsonFormat.Shape.STRING) work?
body: <p>I have the following class that has to be serialized:</p>
  <pre><code>@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&lt;String&gt; countriesSet;
      private boolean isCampaignCbs;
  }
  </code></pre>
  <p>Since it contains BigDecimal fields, I added the annotation</p>
  <pre><code>@JsonFormat(shape=JsonFormat.Shape.STRING)
  </code></pre>
  <p>Unfortunately, it doesn't work and I still get the error:</p>
  <blockquote>
  <p>###UncheckedExecutionException:
  com.fasterxml.jackson.databind.JsonMappingException: N/A  at [Source:
  (byte[])&quot;{&quot;campaignIdToFactorComputationData&quot;:{&quot;1032633420&quot;:{&quot;pacingFactor&quot;:0.001,&quot;pidError&quot;:-0.6111111111111112,&quot;pidIntegral&quot;:0.001,&quot;selectedCountryCode&quot;:&quot;IL&quot;,&quot;targetCappingHourExcluded&quot;:18,&quot;startingHourIncluded&quot;:0,&quot;selectedMarketHistoryDataForCampaign&quot;:{&quot;countryCode&quot;:&quot;IL&quot;,&quot;hourToExpectedEngagePaidListings&quot;:{&quot;1
  0&quot;:10.0,&quot;0 0&quot;:10.0,&quot;23 0&quot;:10.0,&quot;22 0&quot;:10.0,&quot;21 0&quot;:10.0,&quot;20 0&quot;:10.0,&quot;19
  0&quot;:10.0,&quot;18 0&quot;:10.0,&quot;17 0&quot;:10.0,&quot;16 0&quot;:10.0,&quot;15 0&quot;:10.0,&quot;14
  0&quot;:10.0,&quot;13 0&quot;:10.0,&quot;12 0&quot;:10.0,&quot;11 0&quot;:10.0,&quot;10 0&quot;:10.0,&quot;9
  0&quot;:10&quot;[truncated 528 bytes]; line: 1, column: 934] (through reference
  chain:
  ###BudgetPacerCycleOutput[&quot;campaignIdToCurrentData&quot;]-&gt;java.util.LinkedHashMap[&quot;1032633420&quot;]-&gt;###.CampaignCurrentData[&quot;amountSpent&quot;])</p>
  </blockquote>
  <p>I tried to replace the annotations</p>
  <p>@JsonFormat(shape=JsonFormat.Shape.STRING)</p>
  <p>with</p>
  <p>@JsonIgnore</p>
  <p>and I didn't get the error.
  However, I don't want to ignore these fields.
  What can I do?</p>