Are my eyes deceiving me or can I not update a nested node with a JsPath containing an array element in between? (e.g. /a/b(0)/c)
val pnJson = Json.parse("""{"a": {"b": [ {"c": { "d": 1 } } ] } } """)
val pnJsPath = (__ \ "a" \ "b")(0) \ "c"
val pnTrans = pnJsPath.json.update ( __.read[JsObject].map{ _ ++ Json.obj( "e" -> 2 )} )
pnJson.transform(pnTrans)
//result: java.lang.RuntimeException: expected KeyPathNode
If I cant use __.json.update, How can I accomplish this? Trying to accomplish this with immutablity.