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.

有帮助吗?

解决方案

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?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top