"Repaths" the Reads so that successful results have root paths.
"Repaths" the Reads so that successful results have root paths. Use this to transform Readses that output successes with paths in contexts where the successes make more sense at the root.
For example, the path pruning reads outputs a pruned json with the path that it has pruned,
and using withRootPath
on it strips that path:
scala> val json = Json.parse("""{"a": 1, "b": 2}""") json: play.api.libs.json.JsValue = {"a":1,"b":2} scala> (__ \ "b").json.prune.reads(json) res5: play.api.libs.json.JsResult[play.api.libs.json.JsObject] = JsSuccess({"a":1},/b) scala> (__ \ "b").json.prune.withRootPath.reads(json) res6: play.api.libs.json.JsResult[play.api.libs.json.JsObject] = JsSuccess({"a":1},)