-1

Let us say that when I get an HTTP JSON response, I am only interested in some of the JSON fields returned, but not all of them.

Is there a way to unmarshal only some of the fields into my object?

  • What library do you use for handling JSON? Play-json, Circe, Jackson..? – Gaël J May 24 '21 at 18:43
  • I am still trying to make up my mind. I am drawn to Akka HTTP's marhalling/unmarshelling as I am aiming for asynchronous messaging via Futures. However, that is proving to be a bit of an uphill learning curve. So for now, I block, get my JSON from the server and then trying to parse it into scala objects. – Islam Hussein May 25 '21 at 16:06

1 Answers1

2

When you parse a JSON object, you're usually going to map it to a case class. If the JSON object contains more fields than the case class, then the excess fields will simply be ignored by most JSON libraries while unmarshalling.

Matthias Berndt
  • 4,387
  • 1
  • 11
  • 25