![]() | JsonConvert Class |
Namespace: Newtonsoft.Json
public static class JsonConvert
The JsonConvert type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | DefaultSettings |
Gets or sets a function that creates default JsonSerializerSettings.
Default settings are automatically used by serialization methods on JsonConvert,
and ToObjectT and FromObject(Object) on JToken.
To serialize without using any default settings create a JsonSerializer with
Create.
|
Name | Description | |
---|---|---|
![]() ![]() | DeserializeAnonymousTypeT(String, T) |
Deserializes the JSON to the given anonymous type.
|
![]() ![]() | DeserializeAnonymousTypeT(String, T, JsonSerializerSettings) |
Deserializes the JSON to the given anonymous type using JsonSerializerSettings.
|
![]() ![]() | DeserializeObject(String) |
Deserializes the JSON to a .NET object.
|
![]() ![]() | DeserializeObject(String, JsonSerializerSettings) |
Deserializes the JSON to a .NET object using JsonSerializerSettings.
|
![]() ![]() | DeserializeObject(String, Type) |
Deserializes the JSON to the specified .NET type.
|
![]() ![]() | DeserializeObject(String, Type, JsonConverter) |
Deserializes the JSON to the specified .NET type using a collection of JsonConverter.
|
![]() ![]() | DeserializeObject(String, Type, JsonSerializerSettings) |
Deserializes the JSON to the specified .NET type using JsonSerializerSettings.
|
![]() ![]() | DeserializeObjectT(String) |
Deserializes the JSON to the specified .NET type.
|
![]() ![]() | DeserializeObjectT(String, JsonConverter) |
Deserializes the JSON to the specified .NET type using a collection of JsonConverter.
|
![]() ![]() | DeserializeObjectT(String, JsonSerializerSettings) |
Deserializes the JSON to the specified .NET type using JsonSerializerSettings.
|
![]() ![]() | DeserializeXmlNode(String) |
Deserializes the XmlNode from a JSON string.
|
![]() ![]() | DeserializeXmlNode(String, String) |
Deserializes the XmlNode from a JSON string nested in a root element specified by deserializeRootElementName.
|
![]() ![]() | DeserializeXmlNode(String, String, Boolean) |
Deserializes the XmlNode from a JSON string nested in a root element specified by deserializeRootElementName
and writes a Json.NET array attribute for collections.
|
![]() ![]() | DeserializeXmlNode(String, String, Boolean, Boolean) |
Deserializes the XmlNode from a JSON string nested in a root element specified by deserializeRootElementName,
writes a Json.NET array attribute for collections, and encodes special characters.
|
![]() ![]() | DeserializeXNode(String) |
Deserializes the XNode from a JSON string.
|
![]() ![]() | DeserializeXNode(String, String) |
Deserializes the XNode from a JSON string nested in a root element specified by deserializeRootElementName.
|
![]() ![]() | DeserializeXNode(String, String, Boolean) |
Deserializes the XNode from a JSON string nested in a root element specified by deserializeRootElementName
and writes a Json.NET array attribute for collections.
|
![]() ![]() | DeserializeXNode(String, String, Boolean, Boolean) |
Deserializes the XNode from a JSON string nested in a root element specified by deserializeRootElementName,
writes a Json.NET array attribute for collections, and encodes special characters.
|
![]() ![]() | PopulateObject(String, Object) |
Populates the object with values from the JSON string.
|
![]() ![]() | PopulateObject(String, Object, JsonSerializerSettings) |
Populates the object with values from the JSON string using JsonSerializerSettings.
|
![]() ![]() | SerializeObject(Object) |
Serializes the specified object to a JSON string.
|
![]() ![]() | SerializeObject(Object, Formatting) |
Serializes the specified object to a JSON string using formatting.
|
![]() ![]() | SerializeObject(Object, JsonConverter) |
Serializes the specified object to a JSON string using a collection of JsonConverter.
|
![]() ![]() | SerializeObject(Object, JsonSerializerSettings) |
Serializes the specified object to a JSON string using JsonSerializerSettings.
|
![]() ![]() | SerializeObject(Object, Formatting, JsonConverter) |
Serializes the specified object to a JSON string using formatting and a collection of JsonConverter.
|
![]() ![]() | SerializeObject(Object, Formatting, JsonSerializerSettings) |
Serializes the specified object to a JSON string using formatting and JsonSerializerSettings.
|
![]() ![]() | SerializeObject(Object, Type, JsonSerializerSettings) |
Serializes the specified object to a JSON string using a type, formatting and JsonSerializerSettings.
|
![]() ![]() | SerializeObject(Object, Type, Formatting, JsonSerializerSettings) |
Serializes the specified object to a JSON string using a type, formatting and JsonSerializerSettings.
|
![]() ![]() | SerializeXmlNode(XmlNode) |
Serializes the XmlNode to a JSON string.
|
![]() ![]() | SerializeXmlNode(XmlNode, Formatting) |
Serializes the XmlNode to a JSON string using formatting.
|
![]() ![]() | SerializeXmlNode(XmlNode, Formatting, Boolean) |
Serializes the XmlNode to a JSON string using formatting and omits the root object if omitRootObject is true.
|
![]() ![]() | SerializeXNode(XObject) |
Serializes the XNode to a JSON string.
|
![]() ![]() | SerializeXNode(XObject, Formatting) |
Serializes the XNode to a JSON string using formatting.
|
![]() ![]() | SerializeXNode(XObject, Formatting, Boolean) |
Serializes the XNode to a JSON string using formatting and omits the root object if omitRootObject is true.
|
![]() ![]() | ToString(Boolean) |
Converts the Boolean to its JSON string representation.
|
![]() ![]() | ToString(Byte) |
Converts the Byte to its JSON string representation.
|
![]() ![]() | ToString(Char) |
Converts the Char to its JSON string representation.
|
![]() ![]() | ToString(DateTime) |
Converts the DateTime to its JSON string representation.
|
![]() ![]() | ToString(DateTimeOffset) |
Converts the DateTimeOffset to its JSON string representation.
|
![]() ![]() | ToString(Decimal) |
Converts the Decimal to its JSON string representation.
|
![]() ![]() | ToString(Double) |
Converts the Double to its JSON string representation.
|
![]() ![]() | ToString(Enum) |
Converts the Enum to its JSON string representation.
|
![]() ![]() | ToString(Guid) |
Converts the Guid to its JSON string representation.
|
![]() ![]() | ToString(Int16) |
Converts the Int16 to its JSON string representation.
|
![]() ![]() | ToString(Int32) |
Converts the Int32 to its JSON string representation.
|
![]() ![]() | ToString(Int64) |
Converts the Int64 to its JSON string representation.
|
![]() ![]() | ToString(Object) |
Converts the Object to its JSON string representation.
|
![]() ![]() | ToString(SByte) |
Converts the SByte to its JSON string representation.
|
![]() ![]() | ToString(Single) |
Converts the Single to its JSON string representation.
|
![]() ![]() | ToString(String) |
Converts the String to its JSON string representation.
|
![]() ![]() | ToString(TimeSpan) |
Converts the TimeSpan to its JSON string representation.
|
![]() ![]() | ToString(UInt16) |
Converts the UInt16 to its JSON string representation.
|
![]() ![]() | ToString(UInt32) |
Converts the UInt32 to its JSON string representation.
|
![]() ![]() | ToString(UInt64) |
Converts the UInt64 to its JSON string representation.
|
![]() ![]() | ToString(Uri) |
Converts the Uri to its JSON string representation.
|
![]() ![]() | ToString(DateTimeOffset, DateFormatHandling) |
Converts the DateTimeOffset to its JSON string representation using the DateFormatHandling specified.
|
![]() ![]() | ToString(String, Char) |
Converts the String to its JSON string representation.
|
![]() ![]() | ToString(DateTime, DateFormatHandling, DateTimeZoneHandling) |
Converts the DateTime to its JSON string representation using the DateFormatHandling specified.
|
![]() ![]() | ToString(String, Char, StringEscapeHandling) |
Converts the String to its JSON string representation.
|
Name | Description | |
---|---|---|
![]() ![]() | False |
Represents JavaScript's boolean value false as a string. This field is read-only.
|
![]() ![]() | NaN |
Represents JavaScript's NaN as a string. This field is read-only.
|
![]() ![]() | NegativeInfinity |
Represents JavaScript's negative infinity as a string. This field is read-only.
|
![]() ![]() | Null |
Represents JavaScript's null as a string. This field is read-only.
|
![]() ![]() | PositiveInfinity |
Represents JavaScript's positive infinity as a string. This field is read-only.
|
![]() ![]() | True |
Represents JavaScript's boolean value true as a string. This field is read-only.
|
![]() ![]() | Undefined |
Represents JavaScript's undefined as a string. This field is read-only.
|
Product product = new Product(); product.Name = "Apple"; product.ExpiryDate = new DateTime(2008, 12, 28); product.Price = 3.99M; product.Sizes = new string[] { "Small", "Medium", "Large" }; string output = JsonConvert.SerializeObject(product); //{ // "Name": "Apple", // "ExpiryDate": "2008-12-28T00:00:00", // "Price": 3.99, // "Sizes": [ // "Small", // "Medium", // "Large" // ] //} Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);