Stack Overflow Asked on November 16, 2021
I am trying to map a json object to an Entity class. My Json is as follows:
{
"availabilities": {
"2020-07-14T00:00:00Z": "Not Available",
"2020-08-14T00:00:00Z": "Not Available",
"2020-06-14T00:00:00Z": "Not Available",
"2020-05-14T00:00:00Z": "Not Available",
"2020-00-14T00:00:00Z": "Not Available"
}
}
I created a entity class using spring data :
@Entity
public class Availabilities {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String date;
private String availibility;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getAvailibility() {
return availibility;
}
public void setAvailibility(String availibility) {
this.availibility = availibility;
}
}
But i am getting the following error:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "2020-
07-14T00:00:00Z" (class org.abc.hotel.booking.model.Availabilities)
Please help.
your code is trying map by key-value, that mean your variable is the key. in your case. json look like this will work
// map to Availabilities
{
"date": "2020-07-14T00:00:00Z",
"availibility": "Not Available",
}
if you want to parse into a list => How to convert JSON string into List of Java object?
Answered by Hiep Le on November 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP