private JsonPatchResult _Add(JsonValue json) { var(result, success) = JsonPointerFunctions.InsertValue(json, Path, Value); if (!success) { return(new JsonPatchResult(json, "Could not add the value")); } return(new JsonPatchResult(result)); }
private JsonPatchResult _Copy(JsonValue json) { var results = JsonPointer.Parse(From).Evaluate(json); if (results.Error != null) { return(new JsonPatchResult(json, results.Error)); } var(result, success) = JsonPointerFunctions.InsertValue(json, Path, results.Result); if (!success) { return(new JsonPatchResult(json, "Could not add the value")); } return(new JsonPatchResult(result)); }
private JsonPatchResult _Copy(JsonValue json) { var value = JsonPointerFunctions.RetrieveValue(json, From); if (ReferenceEquals(value, null)) { return(new JsonPatchResult(json, $"The path '{Path}' does not exist.")); } var(result, success) = JsonPointerFunctions.InsertValue(json, Path, value); if (!success) { return(new JsonPatchResult(json, "Could not add the value")); } return(new JsonPatchResult(result)); }