I have an array of Json objects. All of these objects follow one of two structures: The first like this:
{
"uuid": "321,
"uuidType": "series",
"title": "a movie",
"segments": [
"movie"
],
"seriesIds": [
"123"
]
}
And the second like this:
{
"uuid": "1234",
"uuidType": "programme",
"title": "programme title",
"type": "movie",
"segments": [
"movies"
],
"programmeIds": [
"321"
]
}
However, I want to parse these objects into the same case class like this:
case class SearchResult(uuid: String, uuidType: String, title: String, segments: List[String], ids: List[String])
So with the second type of object, the type key and value would be ignored, and both seriesIds from the first object and programmeIds from the second object would go into the ids part of the case class. However I have no idea how to do this! I am using Circe to decode/encode the json.
idsfield into the parsed Json AST before turning it into your type.