Class JsonUtil
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
srcdstJsonObjectThe source JSON object to navigate.
jsonObjectPathIEnumerable<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
srcdstJsonObjectThe source JSON object to navigate.
jsonObjectPathIEnumerable<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
filePathstringJSON file path
configNamestringSection name to write
configTConfigSection object to write
Type Parameters
TConfigType of the config object