Show / Hide Table of Contents

Class JsonMergeUtils

Utility class for merging JSON documents.

Inheritance
System.Object
JsonMergeUtils
Namespace: Stac.Common
Assembly: DotNetStac.dll
Syntax
public class JsonMergeUtils : object

Methods

| Improve this Doc View Source

ExtractNullProperties(String)

Extract property names with a null value.

Declaration
public static List<string> ExtractNullProperties(string patch)
Parameters
Type Name Description
System.String patch

JSON Merge patch document.

Returns
Type Description
List<System.String>

The list of null properties.

Remarks

Nested field names are returned joined by "." Array items are ignored.

| Improve this Doc View Source

ExtractNullPropertiesAsync(Stream, CancellationToken)

Extract property names with a null value.

Declaration
public static Task<List<string>> ExtractNullPropertiesAsync(Stream patch, CancellationToken token = null)
Parameters
Type Name Description
Stream patch

JSON Merge patch document.

CancellationToken token

Cancellation token.

Returns
Type Description
Task<List<System.String>>

The list of null properties.

Remarks

Nested field names are returned joined by "." Array items are ignored.

| Improve this Doc View Source

Merge(String, String, Nullable<JsonWriterOptions>)

Return the result of merging the original JSON document with the JSON Merge patch document according to https://tools.ietf.org/html/rfc7386

Declaration
public static string Merge(string original, string patch, JsonWriterOptions? writerOptions = null)
Parameters
Type Name Description
System.String original

Original JSON document to merge new content into.

System.String patch

JSON Merge patch document.

System.Nullable<JsonWriterOptions> writerOptions

Writer options used to write the merge result.

Returns
Type Description
System.String

The document that represents the merge result.

| Improve this Doc View Source

MergeAsync(String, Stream, CancellationToken, Nullable<JsonWriterOptions>)

Return the result of merging the original JSON document with the JSON Merge patch document according to https://tools.ietf.org/html/rfc7386

Declaration
public static Task<string> MergeAsync(string original, Stream patch, CancellationToken token = null, JsonWriterOptions? writerOptions = null)
Parameters
Type Name Description
System.String original

Original JSON document to merge new content into.

Stream patch

JSON Merge patch document.

CancellationToken token

Cancellation token.

System.Nullable<JsonWriterOptions> writerOptions

Writer options used to write the merge result.

Returns
Type Description
Task<System.String>

The document that represents the merge result.

| Improve this Doc View Source

MergeModel<T>(T, String, JsonSerializerOptions)

Apply the result of a JSON merge patch to the given model, using System.Text.Json serializer to serialize and deserialize the model.

Declaration
public static T MergeModel<T>(T original, string patch, JsonSerializerOptions options = null)
Parameters
Type Name Description
T original

Original model to merge new content into.

System.String patch

JSON Merge patch document.

JsonSerializerOptions options

JSON serialization options

Returns
Type Description
T

A new model representing the patched instance.

Type Parameters
Name Description
T

the model type

| Improve this Doc View Source

MergeModelAsync<T>(T, Stream, JsonSerializerOptions, CancellationToken)

Apply the result of a JSON merge patch to the given model, using System.Text.Json serializer to serialize and deserialize the model.

Declaration
public static Task<T> MergeModelAsync<T>(T original, Stream patch, JsonSerializerOptions options = null, CancellationToken token = null)
Parameters
Type Name Description
T original

Original model to merge new content into.

Stream patch

JSON Merge patch document.

JsonSerializerOptions options

JSON serialization options

CancellationToken token

Cancellation token

Returns
Type Description
Task<T>

A task that returns a new model representing the patched instance.

Type Parameters
Name Description
T

the model type

Extension Methods

StacAccessorsHelpers.ToStringByAttributes(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX