DocFX + Singulink = ♥

Class JsonConverter

Converts to and from JSON values.

Inheritance
object
JsonConverter
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SlugBase
Assembly: SlugBase.dll
Syntax
public static class JsonConverter

Methods

View Source

ToDictionary(JsonObject)

Create a mutable copy of a JsonObject.

Declaration
public static Dictionary<string, object> ToDictionary(JsonObject value)
Parameters
Type Name Description
JsonObject value

The JsonObject to copy.

Returns
Type Description
Dictionary<string, object>

A copy of value as a Dictionary<TKey, TValue>.

View Source

ToJson(bool)

Create a JsonAny from a single bool.

Declaration
public static JsonAny ToJson(bool value)
Parameters
Type Name Description
bool value
Returns
Type Description
JsonAny
View Source

ToJson(Dictionary<string, object>)

Create a read-only JsonObject from a copy of obj.

Declaration
public static JsonObject ToJson(Dictionary<string, object> obj)
Parameters
Type Name Description
Dictionary<string, object> obj
Returns
Type Description
JsonObject
Remarks

If null values are valid, use ToJsonAny(object) instead.

Exceptions
Type Condition
ArgumentException

An object in obj could not be converted to JSON.

ArgumentNullException

obj was null.

View Source

ToJson(List<object>)

Create a read-only JsonList from a copy of list.

Declaration
public static JsonList ToJson(List<object> list)
Parameters
Type Name Description
List<object> list
Returns
Type Description
JsonList
Remarks

If null values are valid, use ToJsonAny(object) instead.

Exceptions
Type Condition
ArgumentException

An object in list could not be converted to JSON.

ArgumentNullException

list was null.

View Source

ToJson(double)

Create a JsonAny from a single double.

Declaration
public static JsonAny ToJson(double value)
Parameters
Type Name Description
double value
Returns
Type Description
JsonAny
View Source

ToJson(short)

Create a JsonAny from a single short.

Declaration
public static JsonAny ToJson(short value)
Parameters
Type Name Description
short value
Returns
Type Description
JsonAny
View Source

ToJson(int)

Create a JsonAny from a single int.

Declaration
public static JsonAny ToJson(int value)
Parameters
Type Name Description
int value
Returns
Type Description
JsonAny
View Source

ToJson(long)

Create a JsonAny from a single long. value is converted to a double, so very large numbers may lose precision.

Declaration
public static JsonAny ToJson(long value)
Parameters
Type Name Description
long value
Returns
Type Description
JsonAny
View Source

ToJson(float)

Create a JsonAny from a single float.

Declaration
public static JsonAny ToJson(float value)
Parameters
Type Name Description
float value
Returns
Type Description
JsonAny
View Source

ToJson(string)

Create a JsonAny from a single string.

Declaration
public static JsonAny ToJson(string value)
Parameters
Type Name Description
string value
Returns
Type Description
JsonAny
View Source

ToJson(ushort)

Create a JsonAny from a single ushort.

Declaration
public static JsonAny ToJson(ushort value)
Parameters
Type Name Description
ushort value
Returns
Type Description
JsonAny
View Source

ToJson(uint)

Create a JsonAny from a single uint.

Declaration
public static JsonAny ToJson(uint value)
Parameters
Type Name Description
uint value
Returns
Type Description
JsonAny
View Source

ToJson(ulong)

Create a JsonAny from a single ulong. value is converted to a double, so very large numbers may lose precision.

Declaration
public static JsonAny ToJson(ulong value)
Parameters
Type Name Description
ulong value
Returns
Type Description
JsonAny
View Source

ToJsonAny(object)

Create a read-only JsonAny from a copy of value.

Declaration
public static JsonAny ToJsonAny(object value)
Parameters
Type Name Description
object value
Returns
Type Description
JsonAny
Exceptions
Type Condition
ArgumentException

An object in the list or dictionary could not be converted to JSON.

View Source

ToList(JsonList)

Create a mutable copy of a JsonList.

Declaration
public static List<object> ToList(JsonList value)
Parameters
Type Name Description
JsonList value

The JsonList to copy.

Returns
Type Description
List<object>

A copy of value as a List<T>.

View Source

ToObject(JsonAny)

Create a mutable copy of a JsonAny.

Declaration
public static object ToObject(JsonAny value)
Parameters
Type Name Description
JsonAny value

The JsonAny to copy.

Returns
Type Description
object

A copy of value as a List<T>, Dictionary<TKey, TValue>, string, bool, double, or null.