private def replaceNode()

in http-core/src/main/scala/com/twitter/finatra/http/jsonpatch/JsonPatchOperator.scala [264:276]


  private def replaceNode(path: JsonPointer, value: JsonNode, target: JsonNode): Unit = {
    if (path.tail == null) {
      throw new JsonPatchException("invalid path for replace operation")
    } else if (path.tail.matches) {
      target match {
        case on: ObjectNode => on.set[JsonNode](path.getMatchingProperty, value)
        case an: ArrayNode => an.set(getLeafIndex(path, an, "replace"), value)
        case _ => throw new JsonPatchException("invalid target for replace")
      }
    } else {
      replaceNode(path.tail, value, nextNodeByPath(path, target, "replace"))
    }
  }