Error in mapping to Alphavantage Candle

JsonNode data=jsonNode.path(“Time Series (Daily)”);
Map<LocalDate,AlphavantageCandle> c111;
c111= objectmapper.readValue(re, new TypeReference<HashMap<LocalDate,AlphavantageCandle>>() {});

I have used annotation to ignore the 5th property at class level in Alphavntage candle.I am getting this error.Cannot understand what to do.Stuck on it for almost a day.
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “5. adjusted close” (class com.crio.warmup.stock.dto.AlphavantageCandle), not marked as ignorable (5 known properties: “4. close”, “1. open”, “date”, “3. low”, “2. high”])


Once again check the ignore property, maybe something is wrong with it, the error is reflecting that only.

Checked it.Nothing seems to be wrong.I cannot deserialize the date because there is no field name mentioned.Any hints?

Now I am getting null pointer exception

Their is no field date in JSON response. And you must not put any annotations for date. Use setter to set the date for an object of AlphavantageCandle.

Q. How to do this?

  1. Just see the HashMap in debugger.
  2. Analyze key of HashMap.
  3. If it is a Date then there is a way in java to get a key of hash and iterate over it.
  4. Extract key and use setter to set that attribute for an object.

If you need more clarification reply to this message.

Hi @Patralekha,

I can only assume from your comment that you have resolved the deserialisation issues and you are now facing a null pointer exception somewhere in the code. For us to help you with that, it’ll be prudent to have more details about the error, such as where it is occurring and from where it is originating.

If that’s not the case, then I’ll recommend that you use ignore notation on the whole class, to ignore unknown/unmapped value, not on individual instances inside the class. For them, you don’t need to add an ignore notation. You need to only use the specified unmarshalling methods on properties in API that match the fields. For date, you should iterate through the hashmap and use the setter of the object to set it using the key of the map. Take care here to include only those values that fall within the given range.

If you have any issues implementing this, please let me know!

@Patralekha Is your issue resolved or not?

Yes Sir.It has been resolved.

Closing this topic as your issue has been resolved by the community.