It's probably a very easy question but I'm having trouble finding a clean/working solution. I just want to remove a field from a json object I have. Let's say I have :
val body:Option[JsValue] = request.body.asJson
where body looks like:
{
"url": "www.google.com",
"id": "123",
"count" : 1,
"label" : "test"
}
and I want to remove the field "id" from it.
I have read http://www.playframework.com/documentation/2.1.1/ScalaJsonTransformers case#6 but unfortunately couldn't fully understand it. (I'm pretty new to Scala and functional programming)
Thanks!
This can be done as a JsObject
, which extends JsValue
:
body.as[JsObject] - "id"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With