Class JsonConvert
Provides methods for converting between common language runtime types and JSON types.
Inheritance
Inherited Members
Namespace: Bayat.Json
Assembly: Bayat.Json.Runtime.dll
Syntax
public static class JsonConvert
Examples
Fields
| Improve this Doc View SourceFalse
Represents JavaScript's boolean value false as a string. This field is read-only.
Declaration
public static readonly string False
Field Value
Type | Description |
---|---|
System.String |
NaN
Represents JavaScript's NaN as a string. This field is read-only.
Declaration
public static readonly string NaN
Field Value
Type | Description |
---|---|
System.String |
NegativeInfinity
Represents JavaScript's negative infinity as a string. This field is read-only.
Declaration
public static readonly string NegativeInfinity
Field Value
Type | Description |
---|---|
System.String |
Null
Represents JavaScript's null as a string. This field is read-only.
Declaration
public static readonly string Null
Field Value
Type | Description |
---|---|
System.String |
PositiveInfinity
Represents JavaScript's positive infinity as a string. This field is read-only.
Declaration
public static readonly string PositiveInfinity
Field Value
Type | Description |
---|---|
System.String |
True
Represents JavaScript's boolean value true as a string. This field is read-only.
Declaration
public static readonly string True
Field Value
Type | Description |
---|---|
System.String |
Undefined
Represents JavaScript's undefined as a string. This field is read-only.
Declaration
public static readonly string Undefined
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this Doc View SourceDefaultSettings
Gets or sets a function that creates default JsonSerializerSettings. Default settings are automatically used by serialization methods on JsonConvert, and ToObject<T>() and FromObject(Object) on JToken. To serialize without using any default settings create a JsonSerializer with Create().
Declaration
public static Func<JsonSerializerSettings> DefaultSettings { get; set; }
Property Value
Type | Description |
---|---|
System.Func<JsonSerializerSettings> |
Methods
| Improve this Doc View SourceDeserializeAnonymousType<T>(String, T)
Deserializes the JSON to the given anonymous type.
Declaration
public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
T | anonymousTypeObject | The anonymous type object. |
Returns
Type | Description |
---|---|
T | The deserialized anonymous type from the JSON string. |
Type Parameters
Name | Description |
---|---|
T | The anonymous type to deserialize to. This can't be specified traditionally and must be infered from the anonymous type passed as a parameter. |
DeserializeAnonymousType<T>(String, T, JsonSerializerSettings)
Deserializes the JSON to the given anonymous type using JsonSerializerSettings.
Declaration
public static T DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
T | anonymousTypeObject | The anonymous type object. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
T | The deserialized anonymous type from the JSON string. |
Type Parameters
Name | Description |
---|---|
T | The anonymous type to deserialize to. This can't be specified traditionally and must be infered from the anonymous type passed as a parameter. |
DeserializeObject(String)
Deserializes the JSON to a .NET object.
Declaration
public static object DeserializeObject(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
Returns
Type | Description |
---|---|
System.Object | The deserialized object from the JSON string. |
DeserializeObject(String, JsonSerializerSettings)
Deserializes the JSON to a .NET object using JsonSerializerSettings.
Declaration
public static object DeserializeObject(string value, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Object | The deserialized object from the JSON string. |
DeserializeObject(String, Type)
Deserializes the JSON to the specified .NET type.
Declaration
public static object DeserializeObject(string value, Type type)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
System.Type | type | The System.Type of object being deserialized. |
Returns
Type | Description |
---|---|
System.Object | The deserialized object from the JSON string. |
DeserializeObject(String, Type, JsonConverter[])
Deserializes the JSON to the specified .NET type using a collection of JsonConverter.
Declaration
public static object DeserializeObject(string value, Type type, params JsonConverter[] converters)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
System.Type | type | The type of the object to deserialize. |
JsonConverter[] | converters | Converters to use while deserializing. |
Returns
Type | Description |
---|---|
System.Object | The deserialized object from the JSON string. |
DeserializeObject(String, Type, JsonSerializerSettings)
Deserializes the JSON to the specified .NET type using JsonSerializerSettings.
Declaration
public static object DeserializeObject(string value, Type type, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
System.Type | type | The type of the object to deserialize to. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Object | The deserialized object from the JSON string. |
DeserializeObject<T>(String)
Deserializes the JSON to the specified .NET type.
Declaration
public static T DeserializeObject<T>(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
Returns
Type | Description |
---|---|
T | The deserialized object from the JSON string. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
DeserializeObject<T>(String, JsonConverter[])
Deserializes the JSON to the specified .NET type using a collection of JsonConverter.
Declaration
public static T DeserializeObject<T>(string value, params JsonConverter[] converters)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
JsonConverter[] | converters | Converters to use while deserializing. |
Returns
Type | Description |
---|---|
T | The deserialized object from the JSON string. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
DeserializeObject<T>(String, JsonSerializerSettings)
Deserializes the JSON to the specified .NET type using JsonSerializerSettings.
Declaration
public static T DeserializeObject<T>(string value, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The object to deserialize. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
T | The deserialized object from the JSON string. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
DeserializeObjectAsync(String)
Asynchronously deserializes the JSON to the specified .NET type. Deserialization will happen on a new thread.
Declaration
[Obsolete("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject(value))")]
public static Task<object> DeserializeObjectAsync(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A task that represents the asynchronous deserialize operation. The value of the |
DeserializeObjectAsync(String, Type, JsonSerializerSettings)
Asynchronously deserializes the JSON to the specified .NET type using JsonSerializerSettings. Deserialization will happen on a new thread.
Declaration
[Obsolete("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject(value, type, settings))")]
public static Task<object> DeserializeObjectAsync(string value, Type type, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
System.Type | type | The type of the object to deserialize to. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A task that represents the asynchronous deserialize operation. The value of the |
DeserializeObjectAsync<T>(String)
Asynchronously deserializes the JSON to the specified .NET type. Deserialization will happen on a new thread.
Declaration
[Obsolete("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(value))")]
public static Task<T> DeserializeObjectAsync<T>(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A task that represents the asynchronous deserialize operation. The value of the |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
DeserializeObjectAsync<T>(String, JsonSerializerSettings)
Asynchronously deserializes the JSON to the specified .NET type using JsonSerializerSettings. Deserialization will happen on a new thread.
Declaration
[Obsolete("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(value, settings))")]
public static Task<T> DeserializeObjectAsync<T>(string value, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to deserialize. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | A task that represents the asynchronous deserialize operation. The value of the |
Type Parameters
Name | Description |
---|---|
T | The type of the object to deserialize to. |
DeserializeXmlNode(String)
Deserializes the XmlNode from a JSON string.
Declaration
public static XmlDocument DeserializeXmlNode(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument | The deserialized XmlNode |
DeserializeXmlNode(String, String)
Deserializes the XmlNode from a JSON string nested in a root elment specified by deserializeRootElementName
.
Declaration
public static XmlDocument DeserializeXmlNode(string value, string deserializeRootElementName)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
System.String | deserializeRootElementName | The name of the root element to append when deserializing. |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument | The deserialized XmlNode |
DeserializeXmlNode(String, String, Boolean)
Deserializes the XmlNode from a JSON string nested in a root elment specified by deserializeRootElementName
and writes a .NET array attribute for collections.
Declaration
public static XmlDocument DeserializeXmlNode(string value, string deserializeRootElementName, bool writeArrayAttribute)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
System.String | deserializeRootElementName | The name of the root element to append when deserializing. |
System.Boolean | writeArrayAttribute | A flag to indicate whether to write the Json.NET array attribute. This attribute helps preserve arrays when converting the written XML back to JSON. |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument | The deserialized XmlNode |
DeserializeXNode(String)
Deserializes the System.Xml.Linq.XNode from a JSON string.
Declaration
public static XDocument DeserializeXNode(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
Returns
Type | Description |
---|---|
System.Xml.Linq.XDocument | The deserialized XNode |
DeserializeXNode(String, String)
Deserializes the System.Xml.Linq.XNode from a JSON string nested in a root elment specified by deserializeRootElementName
.
Declaration
public static XDocument DeserializeXNode(string value, string deserializeRootElementName)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
System.String | deserializeRootElementName | The name of the root element to append when deserializing. |
Returns
Type | Description |
---|---|
System.Xml.Linq.XDocument | The deserialized XNode |
DeserializeXNode(String, String, Boolean)
Deserializes the System.Xml.Linq.XNode from a JSON string nested in a root elment specified by deserializeRootElementName
and writes a .NET array attribute for collections.
Declaration
public static XDocument DeserializeXNode(string value, string deserializeRootElementName, bool writeArrayAttribute)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON string. |
System.String | deserializeRootElementName | The name of the root element to append when deserializing. |
System.Boolean | writeArrayAttribute | A flag to indicate whether to write the Json.NET array attribute. This attribute helps preserve arrays when converting the written XML back to JSON. |
Returns
Type | Description |
---|---|
System.Xml.Linq.XDocument | The deserialized XNode |
GetDefaultSettings()
Declaration
public static JsonSerializerSettings GetDefaultSettings()
Returns
Type | Description |
---|---|
JsonSerializerSettings |
PopulateObject(String, Object)
Populates the object with values from the JSON string.
Declaration
public static void PopulateObject(string value, object target)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to populate values from. |
System.Object | target | The target object to populate values onto. |
PopulateObject(String, Object, JsonSerializerSettings)
Populates the object with values from the JSON string using JsonSerializerSettings.
Declaration
public static void PopulateObject(string value, object target, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to populate values from. |
System.Object | target | The target object to populate values onto. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
PopulateObjectAsync(String, Object, JsonSerializerSettings)
Asynchronously populates the object with values from the JSON string using JsonSerializerSettings.
Declaration
[Obsolete("PopulateObjectAsync is obsolete. Use the Task.Factory.StartNew method to populate an object with JSON values asynchronously: Task.Factory.StartNew(() => JsonConvert.PopulateObject(value, target, settings))")]
public static Task PopulateObjectAsync(string value, object target, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The JSON to populate values from. |
System.Object | target | The target object to populate values onto. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to deserialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous populate operation. |
SerializeObject(Object)
Serializes the specified object to a JSON string.
Declaration
public static string SerializeObject(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, Formatting)
Serializes the specified object to a JSON string using formatting.
Declaration
public static string SerializeObject(object value, Formatting formatting)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, Formatting, JsonConverter[])
Serializes the specified object to a JSON string using formatting and a collection of JsonConverter.
Declaration
public static string SerializeObject(object value, Formatting formatting, params JsonConverter[] converters)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
JsonConverter[] | converters | A collection converters used while serializing. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, Formatting, JsonSerializerSettings)
Serializes the specified object to a JSON string using formatting and JsonSerializerSettings.
Declaration
public static string SerializeObject(object value, Formatting formatting, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to serialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, JsonConverter[])
Serializes the specified object to a JSON string using a collection of JsonConverter.
Declaration
public static string SerializeObject(object value, params JsonConverter[] converters)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
JsonConverter[] | converters | A collection converters used while serializing. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, JsonSerializerSettings)
Serializes the specified object to a JSON string using JsonSerializerSettings.
Declaration
public static string SerializeObject(object value, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to serialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, Type, Formatting, JsonSerializerSettings)
Serializes the specified object to a JSON string using a type, formatting and JsonSerializerSettings.
Declaration
public static string SerializeObject(object value, Type type, Formatting formatting, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
System.Type | type | The type of the value being serialized. This parameter is used when TypeNameHandling is Auto to write out the type name if the type of the value does not match. Specifing the type is optional. |
Formatting | formatting | Indicates how the output is formatted. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to serialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObject(Object, Type, JsonSerializerSettings)
Serializes the specified object to a JSON string using a type, formatting and JsonSerializerSettings.
Declaration
public static string SerializeObject(object value, Type type, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
System.Type | type | The type of the value being serialized. This parameter is used when TypeNameHandling is Auto to write out the type name if the type of the value does not match. Specifing the type is optional. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to serialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the object. |
SerializeObjectAsync(Object)
Asynchronously serializes the specified object to a JSON string. Serialization will happen on a new thread.
Declaration
[Obsolete("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value))")]
public static Task<string> SerializeObjectAsync(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A task that represents the asynchronous serialize operation. The value of the |
SerializeObjectAsync(Object, Formatting)
Asynchronously serializes the specified object to a JSON string using formatting. Serialization will happen on a new thread.
Declaration
[Obsolete("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value, formatting))")]
public static Task<string> SerializeObjectAsync(object value, Formatting formatting)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A task that represents the asynchronous serialize operation. The value of the |
SerializeObjectAsync(Object, Formatting, JsonSerializerSettings)
Asynchronously serializes the specified object to a JSON string using formatting and a collection of JsonConverter. Serialization will happen on a new thread.
Declaration
[Obsolete("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value, formatting, settings))")]
public static Task<string> SerializeObjectAsync(object value, Formatting formatting, JsonSerializerSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
JsonSerializerSettings | settings | The JsonSerializerSettings used to serialize the object. If this is null, default serialization settings will be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A task that represents the asynchronous serialize operation. The value of the |
SerializeXmlNode(XmlNode)
Serializes the XML node to a JSON string.
Declaration
public static string SerializeXmlNode(XmlNode node)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlNode | node | The node to serialize. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XmlNode. |
SerializeXmlNode(XmlNode, Formatting)
Serializes the XML node to a JSON string using formatting.
Declaration
public static string SerializeXmlNode(XmlNode node, Formatting formatting)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlNode | node | The node to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XmlNode. |
SerializeXmlNode(XmlNode, Formatting, Boolean)
Serializes the XML node to a JSON string using formatting and omits the root object if omitRootObject
is true
.
Declaration
public static string SerializeXmlNode(XmlNode node, Formatting formatting, bool omitRootObject)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlNode | node | The node to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
System.Boolean | omitRootObject | Omits writing the root object. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XmlNode. |
SerializeXNode(XObject)
Serializes the System.Xml.Linq.XNode to a JSON string.
Declaration
public static string SerializeXNode(XObject node)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Linq.XObject | node | The node to convert to JSON. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XNode. |
SerializeXNode(XObject, Formatting)
Serializes the System.Xml.Linq.XNode to a JSON string using formatting.
Declaration
public static string SerializeXNode(XObject node, Formatting formatting)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Linq.XObject | node | The node to convert to JSON. |
Formatting | formatting | Indicates how the output is formatted. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XNode. |
SerializeXNode(XObject, Formatting, Boolean)
Serializes the System.Xml.Linq.XNode to a JSON string using formatting and omits the root object if omitRootObject
is true
.
Declaration
public static string SerializeXNode(XObject node, Formatting formatting, bool omitRootObject)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.Linq.XObject | node | The node to serialize. |
Formatting | formatting | Indicates how the output is formatted. |
System.Boolean | omitRootObject | Omits writing the root object. |
Returns
Type | Description |
---|---|
System.String | A JSON string of the XNode. |
ToString(Boolean)
Converts the System.Boolean to its JSON string representation.
Declaration
public static string ToString(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Boolean. |
ToString(Byte)
Converts the System.Byte to its JSON string representation.
Declaration
public static string ToString(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Byte. |
ToString(Char)
Converts the System.Char to its JSON string representation.
Declaration
public static string ToString(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Char. |
ToString(DateTime)
Converts the System.DateTime to its JSON string representation.
Declaration
public static string ToString(DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.DateTime. |
ToString(DateTime, DateFormatHandling, DateTimeZoneHandling)
Converts the System.DateTime to its JSON string representation using the DateFormatHandling specified.
Declaration
public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value to convert. |
DateFormatHandling | format | The format the date will be converted to. |
DateTimeZoneHandling | timeZoneHandling | The time zone handling when the date is converted to a string. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.DateTime. |
ToString(DateTimeOffset)
Converts the System.DateTimeOffset to its JSON string representation.
Declaration
public static string ToString(DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.DateTimeOffset. |
ToString(DateTimeOffset, DateFormatHandling)
Converts the System.DateTimeOffset to its JSON string representation using the DateFormatHandling specified.
Declaration
public static string ToString(DateTimeOffset value, DateFormatHandling format)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | value | The value to convert. |
DateFormatHandling | format | The format the date will be converted to. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.DateTimeOffset. |
ToString(Decimal)
Converts the System.Decimal to its JSON string representation.
Declaration
public static string ToString(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.SByte. |
ToString(Double)
Converts the System.Double to its JSON string representation.
Declaration
public static string ToString(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Double. |
ToString(Double, FloatFormatHandling, Char, Boolean)
Declaration
public static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | |
FloatFormatHandling | floatFormatHandling | |
System.Char | quoteChar | |
System.Boolean | nullable |
Returns
Type | Description |
---|---|
System.String |
ToString(Enum)
Converts the System.Enum to its JSON string representation.
Declaration
public static string ToString(Enum value)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Enum. |
ToString(Guid)
Converts the System.Guid to its JSON string representation.
Declaration
public static string ToString(Guid value)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Guid. |
ToString(Guid, Char)
Declaration
public static string ToString(Guid value, char quoteChar)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | value | |
System.Char | quoteChar |
Returns
Type | Description |
---|---|
System.String |
ToString(Int16)
Converts the System.Int16 to its JSON string representation.
Declaration
public static string ToString(short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Int16. |
ToString(Int32)
Converts the System.Int32 to its JSON string representation.
Declaration
public static string ToString(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Int32. |
ToString(Int64)
Converts the System.Int64 to its JSON string representation.
Declaration
public static string ToString(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Int64. |
ToString(Object)
Converts the System.Object to its JSON string representation.
Declaration
public static string ToString(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Object. |
ToString(SByte)
Converts the System.SByte to its JSON string representation.
Declaration
public static string ToString(sbyte value)
Parameters
Type | Name | Description |
---|---|---|
System.SByte | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.SByte. |
ToString(Single)
Converts the System.Single to its JSON string representation.
Declaration
public static string ToString(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Single. |
ToString(Single, FloatFormatHandling, Char, Boolean)
Declaration
public static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | |
FloatFormatHandling | floatFormatHandling | |
System.Char | quoteChar | |
System.Boolean | nullable |
Returns
Type | Description |
---|---|
System.String |
ToString(String)
Converts the System.String to its JSON string representation.
Declaration
public static string ToString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.String. |
ToString(String, Char)
Converts the System.String to its JSON string representation.
Declaration
public static string ToString(string value, char delimiter)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
System.Char | delimiter | The string delimiter character. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.String. |
ToString(String, Char, StringEscapeHandling)
Converts the System.String to its JSON string representation.
Declaration
public static string ToString(string value, char delimiter, StringEscapeHandling stringEscapeHandling)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to convert. |
System.Char | delimiter | The string delimiter character. |
StringEscapeHandling | stringEscapeHandling | The string escape handling. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.String. |
ToString(TimeSpan)
Converts the System.TimeSpan to its JSON string representation.
Declaration
public static string ToString(TimeSpan value)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.TimeSpan. |
ToString(TimeSpan, Char)
Declaration
public static string ToString(TimeSpan value, char quoteChar)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | value | |
System.Char | quoteChar |
Returns
Type | Description |
---|---|
System.String |
ToString(UInt16)
Converts the System.UInt16 to its JSON string representation.
Declaration
public static string ToString(ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.UInt16. |
ToString(UInt32)
Converts the System.UInt32 to its JSON string representation.
Declaration
public static string ToString(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.UInt32. |
ToString(UInt64)
Converts the System.UInt64 to its JSON string representation.
Declaration
public static string ToString(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.UInt64. |
ToString(Uri)
Converts the System.Uri to its JSON string representation.
Declaration
public static string ToString(Uri value)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | value | The value to convert. |
Returns
Type | Description |
---|---|
System.String | A JSON string representation of the System.Uri. |
ToString(Uri, Char)
Declaration
public static string ToString(Uri value, char quoteChar)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | value | |
System.Char | quoteChar |
Returns
Type | Description |
---|---|
System.String |