Class JsonNet
Internally used utilities for JSON serialization and deserialization using Newtonsoft.Json
Assembly: Glitch9.dll
Syntax
public static class JsonNet
Fields
|
Edit this page
View Source
MaxJsonLength
Declaration
public const int MaxJsonLength = 1000000
Field Value
Properties
|
Edit this page
View Source
DefaultJss
Declaration
public static JsonSerializerSettings DefaultJss { get; set; }
Property Value
| Type |
Description |
| JsonSerializerSettings |
|
Methods
|
Edit this page
View Source
DeserializeFile<T>(string, JsonSerializerSettings, bool)
Declaration
public static T DeserializeFile<T>(string jsonFilePath, JsonSerializerSettings jss = null, bool deleteIfError = false)
Parameters
| Type |
Name |
Description |
| string |
jsonFilePath |
|
| JsonSerializerSettings |
jss |
|
| bool |
deleteIfError |
|
Returns
Type Parameters
|
Edit this page
View Source
DeserializeNested<T>(string, string, JsonSerializerSettings)
Declaration
public static T DeserializeNested<T>(string parentProperty, string json, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| string |
parentProperty |
|
| string |
json |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
Deserialize<T>(string, JsonSerializerSettings)
Declaration
public static T Deserialize<T>(string json, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| string |
json |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
EscapeJson(string)
Escapes JSON string characters.
Declaration
public static string EscapeJson(string text)
Parameters
| Type |
Name |
Description |
| string |
text |
|
Returns
|
Edit this page
View Source
ReadNestedJsonString(string, string)
Declaration
public static string ReadNestedJsonString(string json, string propertyName)
Parameters
Returns
|
Edit this page
View Source
ReadNestedString(string, string, string)
Scans the JSON and returns the value of a nested property without building a JObject.
Declaration
public static string ReadNestedString(string json, string parentProperty, string propertyName)
Parameters
Returns
|
Edit this page
View Source
ReadString(string, string)
Scans the JSON and returns the value of a specific property without building a JObject.
Such as 'type', or 'message'.
Declaration
public static string ReadString(string json, string propertyName)
Parameters
Returns
|
Edit this page
View Source
SafeSerializeArray<T>(IList<T>, JsonSerializer)
Serializes array elements individually, skipping corrupted items.
Any problematic elements are logged and skipped.
Declaration
public static string SafeSerializeArray<T>(IList<T> array, JsonSerializer serializer)
Parameters
| Type |
Name |
Description |
| IList<T> |
array |
|
| JsonSerializer |
serializer |
|
Returns
Type Parameters
|
Edit this page
View Source
SafeSerializeArray<T>(IList<T>, JsonSerializerSettings)
Serializes array elements individually, skipping corrupted items.
Any problematic elements are logged and skipped.
Declaration
public static string SafeSerializeArray<T>(IList<T> array, JsonSerializerSettings jss)
Parameters
| Type |
Name |
Description |
| IList<T> |
array |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
SerializeFile<T>(string, T, JsonSerializerSettings)
Declaration
public static string SerializeFile<T>(string jsonFilePath, T obj, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| string |
jsonFilePath |
|
| T |
obj |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
SerializePretty<T>(T, JsonSerializerSettings)
Declaration
public static string SerializePretty<T>(T obj, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| T |
obj |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
Serialize<T>(T, JsonSerializerSettings)
Declaration
public static string Serialize<T>(T obj, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| T |
obj |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters
|
Edit this page
View Source
VerboseLog<T>(T, string, JsonSerializerSettings)
Declaration
public static string VerboseLog<T>(T obj, string fallbackLog, JsonSerializerSettings jss = null)
Parameters
| Type |
Name |
Description |
| T |
obj |
|
| string |
fallbackLog |
|
| JsonSerializerSettings |
jss |
|
Returns
Type Parameters