How do I replace a value in a JSON value in Play?
Code to illustrate:
def newReport() = Action(parse.json) { request =>
var json = request.bod
a glorified version of Zeimyth's answer that uses implicit conversion
implicit class JsObjectEnhancer(jsObject: JsObject) {
def update(args: (String, Json.JsValueWrapper)*): JsObject = {
jsObject ++ Json.obj(args: _*)
}
}
usage (json must be of type JsObject and the implicit class should be in scope)
json.update("customerId", 1000)