JsonPatchDocument Class

Namespace
Microsoft.AspNetCore.JsonPatch
Assemblies
  • Microsoft.AspNetCore.JsonPatch

Syntax

[JsonConverter(typeof (JsonPatchDocumentConverter))]
public class JsonPatchDocument : IJsonPatchDocument
class Microsoft.AspNetCore.JsonPatch.JsonPatchDocument

Constructors

JsonPatchDocument()
public JsonPatchDocument()
JsonPatchDocument(System.Collections.Generic.List<Microsoft.AspNetCore.JsonPatch.Operations.Operation>, Newtonsoft.Json.Serialization.IContractResolver)
public JsonPatchDocument(List<Operation> operations, IContractResolver contractResolver)

Methods

Add(System.String, System.Object)

Add operation. Will result in, for example, { “op”: “add”, “path”: “/a/b/c”, “value”: [ “foo”, “bar” ] }

Arguments:
  • path (System.String) – target location
  • value (System.Object) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument

public JsonPatchDocument Add(string path, object value)
ApplyTo(System.Object)

Apply this JsonPatchDocument

Arguments:objectToApplyTo (System.Object) – Object to apply the JsonPatchDocument to
public void ApplyTo(object objectToApplyTo)
ApplyTo(System.Object, Microsoft.AspNetCore.JsonPatch.Adapters.IObjectAdapter)

Apply this JsonPatchDocument

Arguments:
public void ApplyTo(object objectToApplyTo, IObjectAdapter adapter)
ApplyTo(System.Object, System.Action<Microsoft.AspNetCore.JsonPatch.JsonPatchError>)

Apply this JsonPatchDocument

Arguments:
public void ApplyTo(object objectToApplyTo, Action<JsonPatchError> logErrorAction)
Copy(System.String, System.String)

Copy the value at specified location to the target location. Willr esult in, for example: { “op”: “copy”, “from”: “/a/b/c”, “path”: “/a/b/e” }

Arguments:
  • from (System.String) – source location
  • path (System.String) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument

public JsonPatchDocument Copy(string from, string path)
GetOperations()
Return type:System.Collections.Generic.IList<Microsoft.AspNetCore.JsonPatch.Operations.Operation>
IList<Operation> IJsonPatchDocument.GetOperations()
Move(System.String, System.String)

Removes value at specified location and add it to the target location. Will result in, for example: { “op”: “move”, “from”: “/a/b/c”, “path”: “/a/b/d” }

Arguments:
  • from (System.String) – source location
  • path (System.String) – target location
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument

public JsonPatchDocument Move(string from, string path)
Remove(System.String)

Remove value at target location. Will result in, for example, { “op”: “remove”, “path”: “/a/b/c” }

Arguments:path (System.String) – target location
Return type:Microsoft.AspNetCore.JsonPatch.JsonPatchDocument
public JsonPatchDocument Remove(string path)
Replace(System.String, System.Object)

Replace value. Will result in, for example, { “op”: “replace”, “path”: “/a/b/c”, “value”: 42 }

Arguments:
  • path (System.String) – target location
  • value (System.Object) – value
Return type:

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument

public JsonPatchDocument Replace(string path, object value)

Properties

Microsoft.AspNetCore.JsonPatch.JsonPatchDocument.ContractResolver
Return type:Newtonsoft.Json.Serialization.IContractResolver
[JsonIgnore]
public IContractResolver ContractResolver { get; set; }
Microsoft.AspNetCore.JsonPatch.JsonPatchDocument.Operations
Return type:System.Collections.Generic.List<Microsoft.AspNetCore.JsonPatch.Operations.Operation>
public List<Operation> Operations { get; }