문제

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