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
jsonObjectJsonObjectthe JsonObject
arrayPropertyNamestringthe name of the JsonArray property
itemTItemthe item to add
loggerILoggerthe ILogger
Type Parameters
TItemthe 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
jObjectJsonObjectthe JsonObject
truncationLengthintthe number of characters to display for each property
Returns
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
jObjectJsonObjectthe JsonObject
targetPropertyNamestringthe target property name
loggerILoggerthe ILogger
Returns
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
documentDataJsonObjectthe JsonObject
loggerILoggerthe ILogger
operations(string oldName, string newName)[]specifies which JsonObject properties to rename