Question

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.

Était-ce utile?

La solution

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?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top