Frage

How does I deserialise data like this into a case class like this:

case class SoundCloudUser (
  id: Int,
  permalink: String,
  username: String,
  country: String,
  full_name: String,
  city: String,
  description: String)

(that is, where the case class has less constructor arguments than the JSON has values)

I tried creating a FieldSerializer to do this, but I could only work out how to ignore fields when serialising, not deserialising.

War es hilfreich?

Lösung

As long as the fields in the JSON data are a superset of the fields in your case class, you don't need to do anything special to ignore the fields in the JSON data that aren't in your case class. It should "just work". Are you getting any errors?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top