Play Framework – add a field to JSON object
JsObject has a + method that allows you to add fields to an object, but unfortunately your jsonObject is statically typed as a JsValue, not a JsObject. You can get around this in a couple of ways. The first is to use as: scala> jsonObject.as[JsObject] + (“c” -> Json.toJson(3)) res0: play.api.libs.json.JsObject = {“a”:1,”b”:2,”c”:3} With as … Read more