Class JsonConversion
public static class JsonConversion
- Inheritance
-
JsonConversion
- Inherited Members
Methods
FromJson<T>(JsonData, JsonConverterSet, bool)
Attempts to convert the JSON data into a C# object of the given type.
public static T FromJson<T>(JsonData jsonData, JsonConversion.JsonConverterSet customConverters, bool allowUndefinedConversions = false)
Parameters
jsonDataJsonDataThe JSON data to convert.
customConvertersJsonConversion.JsonConverterSetA collection of JsonConverter objects that defined custom conversions for certain data types.
allowUndefinedConversionsboolIf false, an exception will be thrown if the code encounters a type that can not be converted using conversions for primitive JSON types and/or custom converters.
Returns
- T
Type Parameters
TThe type to convert the JSON into.
FromJson<T>(JsonData, JsonConverterSet, bool, HashSet<JsonData>)
Attempts to convert the JSON data into a C# object of the given type.
public static T FromJson<T>(JsonData jsonData, JsonConversion.JsonConverterSet customConverters, bool allowUndefinedConversions, HashSet<JsonData> dataAlreadyTryingToConvert)
Parameters
jsonDataJsonDataThe JSON data to convert.
customConvertersJsonConversion.JsonConverterSetA collection of JsonConverter objects that defined custom conversions for certain data types.
allowUndefinedConversionsboolIf false, an exception will be thrown if the code encounters a type that can not be converted using conversions for primitive JSON types and/or custom converters.
dataAlreadyTryingToConvertHashSet<JsonData>The JSON data objects trying to be converted in the current function call stack. Used to prevent infinite loops when converting objects with circular references.
Returns
- T
Type Parameters
TThe type to convert the JSON into.
FromJson<T>(JsonData, bool)
Attempts to convert the JSON data into a C# object of the given type.
public static T FromJson<T>(JsonData jsonData, bool allowUndefinedConversions = false)
Parameters
jsonDataJsonDataThe JSON data to convert.
allowUndefinedConversionsboolIf false, an exception will be thrown if the code encounters a type that can not be converted using conversions for primitive JSON types and/or custom converters.
Returns
- T
Type Parameters
TThe type to convert the JSON into.
ToJson(object, JsonConverterSet, bool)
Attempts to convert the C# object into JSON data.
NOTE: When converting an enum value which has more than one name, one of those names will be chosen, but not necessarily the one originally used to assign that value. E.g. for an enum with values Value1 = 0, Value2 = 0, Value3 = 1, converting Value1 into JSON may end up as "Value2".
public static JsonData ToJson(object obj, JsonConversion.JsonConverterSet customConverters, bool allowUndefinedConversions = false)
Parameters
objobjectThe object to convert into JSON.
customConvertersJsonConversion.JsonConverterSetA collection of JsonConverter objects that defined custom conversions for certain data types.
allowUndefinedConversionsboolIf false, an exception will be thrown if the code encounters a type that can not be converted using conversions for primitive JSON types and/or custom converters.
Returns
ToJson(object, bool)
Attempts to convert the C# object into JSON data.
NOTE: When converting an enum value which has more than one name, one of those names will be chosen, but not necessarily the one originally used to assign that value. E.g. for an enum with values Value1 = 0, Value2 = 0, Value3 = 1, converting Value1 into JSON may end up as "Value2".
public static JsonData ToJson(object obj, bool allowUndefinedConversions = false)
Parameters
objobjectThe object to convert into JSON.
allowUndefinedConversionsboolIf false, an exception will be thrown if the code encounters a type that can not be converted using conversions for primitive JSON types and/or custom converters.