Reputation: 2811
lets say I have this simple json as JsObject:
val simpleJson = Json.parse("""{
"name" : "Watership Down"
}""".stripMargin).as[JsObject]
and I want to change the "name" value, how would I do that on JsObject?
Upvotes: 0
Views: 73
Reputation: 1142
As @Levi Ramsey said, just without the Play Json wrappers:
simpleJson ++ Json.obj("name" -> "Spaceship Up");
From Play 2.4.X
you can use +
:
simpleJson + ("name" -> "Spaceship Up");
https://scastie.scala-lang.org/bvAXZw8TSTetuWJcMeQU0Q
Upvotes: 1
Reputation: 20561
simpleJson ++ JsObject(Map("name": JsString("Spaceship Up")))
++
merges two JsObject
s, with the right-hand-side taking precedence.
Upvotes: 0