Table of Contents

Class JsonObjectExtensions

Namespace
Songhay.Extensions
Assembly
SonghayCore.dll

Extensions of JsonNode.

public static class JsonObjectExtensions
Inheritance
JsonObjectExtensions
Inherited Members

Remarks

To prevent passing null instances of ILogger into these methods, use AsInstanceOrNullLogger(ILogger?).

Methods

AddItemToArray<TItem>(JsonObject?, string?, TItem?, ILogger)

Adds the specified item to the JsonArray of the specified JsonObject.

public static void AddItemToArray<TItem>(this JsonObject? jsonObject, string? arrayPropertyName, TItem? item, ILogger logger)

Parameters

jsonObject JsonObject

the JsonObject

arrayPropertyName string

the name of the JsonArray property

item TItem

the item to add

logger ILogger

the ILogger

Type Parameters

TItem

the type of the item to add

DisplayTopProperties(JsonObject?, int)

Displays top-level JsonObject properties without recursion.

public static string DisplayTopProperties(this JsonObject? jObject, int truncationLength = 16)

Parameters

jObject JsonObject

the JsonObject

truncationLength int

the number of characters to display for each property

Returns

string

GetPropertyJsonNodeOrNull(JsonObject?, string?, ILogger)

Returns the JsonNode of the specified target property name or null.

public static JsonNode? GetPropertyJsonNodeOrNull(this JsonObject? jObject, string? targetPropertyName, ILogger logger)

Parameters

jObject JsonObject

the JsonObject

targetPropertyName string

the target property name

logger ILogger

the ILogger

Returns

JsonNode

WithPropertiesRenamed(JsonObject?, ILogger, params (string oldName, string newName)[])

Returns the specified JsonObject with its properties renamed.

public static JsonObject? WithPropertiesRenamed(this JsonObject? documentData, ILogger logger, params (string oldName, string newName)[] operations)

Parameters

documentData JsonObject

the JsonObject

logger ILogger

the ILogger

operations (string oldName, string newName)[]

specifies which JsonObject properties to rename

Returns

JsonObject