Class JsonHelpers
JSON reading and writing utilities.
public static class JsonHelpers
- Inheritance
-
JsonHelpers
- Inherited Members
Fields
Options
The default JSON serialisation options.
public static readonly JsonSerializerOptions Options
Field Value
Methods
Create(JsonSerializerOptions)
Creates a JsonSerializerOptions which has the basic
properties of Options, but the converters of options.
public static JsonSerializerOptions Create(JsonSerializerOptions options)
Parameters
optionsJsonSerializerOptions
Returns
LoadFrom<T>(string)
Reads JSON data from path and returns it as a/an T.
public static T? LoadFrom<T>(string path) where T : class
Parameters
pathstring
Returns
- T
trueon success,falseif the file cannot be found.
Type Parameters
T
LoadFrom<T>(string, JsonSerializerOptions)
Reads JSON data from path and returns it as a/an T.
Also uses custom JSON serialisation options.
public static T? LoadFrom<T>(string path, JsonSerializerOptions options) where T : class
Parameters
pathstringoptionsJsonSerializerOptions
Returns
- T
trueon success,falseif the file cannot be found.
Type Parameters
T
LoadFrom<T>(ref T, string)
Reads JSON data from path and stores it into
outObject.
public static bool LoadFrom<T>(ref T outObject, string path) where T : struct
Parameters
outObjectTpathstring
Returns
- bool
trueon success,falseif the file cannot be found.
Type Parameters
T
LoadFrom<T>(ref T, string, JsonSerializerOptions)
Reads JSON data from path and stores it into
outObject. Uses custom options also.
public static bool LoadFrom<T>(ref T outObject, string path, JsonSerializerOptions options) where T : struct
Parameters
outObjectTpathstringoptionsJsonSerializerOptions
Returns
- bool
trueon success,falseif the file cannot be found.
Type Parameters
T
Write<T>(T, string)
Writes what into a file path.
public static bool Write<T>(T what, string path)
Parameters
whatTpathstring
Returns
- bool
trueon success,falseif the path is invalid.
Type Parameters
T