Table of Contents

Class JsonUtils

Namespace
Nautilus.Utility
Assembly
Nautilus.dll
A collection of utilities for interacting with JSON files.
public static class JsonUtils
Inheritance
JsonUtils
Inherited Members

Methods

Load<T>(string, bool, params JsonConverter[])

Create an instance of T, populated with data from the JSON file at the given path.
public static T Load<T>(string path = null, bool createFileIfNotExist = true, params JsonConverter[] jsonConverters) where T : class, new()

Parameters

path string
The path on disk at which the JSON file can be found.
createFileIfNotExist bool
Whether a new JSON file should be created with default values if it does not already exist.
jsonConverters JsonConverter[]
An array of Newtonsoft.Json.JsonConverters to be used for deserialization.

Returns

T
The T instance populated with data from the JSON file at path, or default values if it cannot be found or an error is encountered while parsing the file.

Type Parameters

T
The type of object to initialise and populate with JSON data.
See Also

Load<T>(T, string, bool, params JsonConverter[])

Loads data from the JSON file at path into the jsonObject.
public static void Load<T>(T jsonObject, string path = null, bool createFileIfNotExist = true, params JsonConverter[] jsonConverters) where T : class

Parameters

jsonObject T
The T instance to popular with JSON data.
path string
The path on disk at which the JSON file can be found.
createFileIfNotExist bool
Whether a new JSON file should be created with default values if it does not already exist.
jsonConverters JsonConverter[]
An array of Newtonsoft.Json.JsonConverters to be used for deserialization.

Type Parameters

T
The type of jsonObject to populate with JSON data.
See Also

Save<T>(T, string, params JsonConverter[])

Saves the jsonObject parsed as JSON data to the JSON file at path, creating it if it does not exist.
public static void Save<T>(T jsonObject, string path = null, params JsonConverter[] jsonConverters) where T : class

Parameters

jsonObject T
The T instance to parse into JSON data.
path string
The path on disk at which to store the JSON file.
jsonConverters JsonConverter[]
An array of Newtonsoft.Json.JsonConverters to be used for serialization.

Type Parameters

T
The type of jsonObject to parse into JSON data.
See Also