Table of Contents

Class JsonUtil

Namespace
Hi.Common
Assembly
HiGeom.dll

Helper utilities for reading and writing JSON files.

public static class JsonUtil
Inheritance
JsonUtil
Inherited Members

Methods

CallJsonArrayByPath(JsonObject, IEnumerable<string>)

Navigates or creates a JSON array path in the source JSON object. Creates missing intermediate objects and the final array as needed.

public static JsonArray CallJsonArrayByPath(this JsonObject srcdst, IEnumerable<string> jsonObjectPath)

Parameters

srcdst JsonObject

The source JSON object to navigate.

jsonObjectPath IEnumerable<string>

The path segments to navigate through. The last segment will be treated as an array.

Returns

JsonArray

The JSON array at the specified path, creating it if it doesn't exist. Returns null if the path is empty.

CallJsonObjectByPath(JsonObject, IEnumerable<string>)

Navigates or creates a JSON object path in the source JSON object. Creates missing intermediate objects as needed.

public static JsonObject CallJsonObjectByPath(this JsonObject srcdst, IEnumerable<string> jsonObjectPath)

Parameters

srcdst JsonObject

The source JSON object to navigate.

jsonObjectPath IEnumerable<string>

The path segments to navigate through.

Returns

JsonObject

The JSON object at the specified path, creating it if it doesn't exist.

WritePartialJson<TConfig>(string, string, TConfig)

Writes a config object into a named section of a JSON file; merges when file exists and overwrites the same section name.

public static void WritePartialJson<TConfig>(string filePath, string configName, TConfig config)

Parameters

filePath string

JSON file path

configName string

Section name to write

config TConfig

Section object to write

Type Parameters

TConfig

Type of the config object