I am trying to parse json using case class but running into an issue.
I have the following json
{
"general": {
"table": "123",
},
"employee" : {
"table": "employee_data"
},
"fulltime" : {
"table": "fulltime_employee_data"
},
"consultant" : {
"table": "consultant_employee_data"
}
}
Here's my case class:
case class EmployeeInfo(employees: List[Map[String, String]])
I'm trying to parse the above json using the case class using the following code. It returns the object as null.
val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(new JavaTimeModule())
mapper.registerModule(DefaultScalaModule)
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
val str = Source.fromFile("employeeInfo.json").mkString
val temp = mapper.readValue[EmployeeInfo](str)
temp here is being returned as null. My json seems to be list of maps which is what I provided in my case class. Any thoughts on what I'm missing?