I am using Play! Scala 2.2, and I have a problem displaying class in Json :
I have two classes with one depending on the other, as follows:
case class Artist(id: String, cover: String, website: List[String], link: String, Tracks: List[Track] = List()) case class Track(stream_url: String, title: String, artwork_url: Option[String] )
And their implicit writers:
implicit val artistWrites: Writes[Artist] = Json.writes[Artist] implicit val trackWrites: Writes[Track] = Json.writes[Track]
Authors work well, as shown below:
println(Json.toJson(Track("aaa", "aaa", Some("aaa")))) println(Json.toJson(Artist("aaa", "aaa", List("aaa"), "aaa", List())))
ie, if Artist has an empty list of tracks . But if I want to do this:
println(Json.toJson(Artist("aaa", "aaa", List("aaa"), "aaa", List(SoundCloudTrack("ljkjk", "ljklkj", Some("lkjljk"))))))
I get a execution exception : [NullPointerException: null]
Could you explain to me what I am doing wrong? Thanks;)