Class JsonConverter
- Namespace
- Dynamicweb.Core.Json
- Assembly
- Dynamicweb.Core.dll
This class provides methods that can serialize and deserialize objects to and from Json.
public class JsonConverter
- Inheritance
-
JsonConverter
- Inherited Members
Properties
Current
Gets currently used jsonhelper
public static JsonConverter Current { get; }
Property Value
CurrentCompacted
Gets currently used jsonhelper specialized towards compacted data storage
public static JsonConverter CurrentCompacted { get; }
Property Value
Settings
Settings used when the Convert methods are being employed.
public JsonSerializerSettings Settings { get; set; }
Property Value
- JsonSerializerSettings
Methods
Convert<T>(T)
Converts the object to a json string.
public static string Convert<T>(T obj)
Parameters
obj
T- Object to serialize
Returns
- string
- jsonString
Type Parameters
T
- Type of object
Convert<T>(string)
Json data to deserialize into an object.
public static T Convert<T>(string data)
Parameters
data
string- Json string
Returns
- T
- object
Type Parameters
T
- Type of object
ConvertToArray(JArray)
Legacy support. Dont use in new code.
public static object[] ConvertToArray(JArray jsonArray)
Parameters
jsonArray
JArray
Returns
- object[]
ConvertToDictionary(JObject)
Legacy support. Dont use in new code.
public static IDictionary<string, object> ConvertToDictionary(JObject jsonObject)
Parameters
jsonObject
JObject
Returns
Deserialize<T>(string)
Json data to deserialize into an object, using current settings.
public T Deserialize<T>(string data)
Parameters
data
string- Json string
Returns
- T
- object
Type Parameters
T
- Type of object
Deserialize<T>(string, JsonSettings)
Json data to deserialize into an object.
public static T Deserialize<T>(string data, JsonSettings settings)
Parameters
data
string- Json string
settings
JsonSettings- Settings for deserialization
Returns
- T
- object
Type Parameters
T
- Type of object
DeserializeObject(string)
Legacy use only.
public static object DeserializeObject(string json)
Parameters
json
string- Json string
Returns
- object
- JObject or similar
DeserializeXmlNode(string)
Deserializes the XmlNode from a JSON string.
public static XmlDocument DeserializeXmlNode(string value)
Parameters
value
string- The JSON string
Returns
- XmlDocument
- The deserialized XmlNode
DeserializeXmlNode(string, string)
Deserializes the XmlNode from a JSON string nested in a root elment specified by deserializeRootElementName.
public static XmlDocument DeserializeXmlNode(string value, string deserializeRootElementName)
Parameters
Returns
- XmlDocument
- The deserialized XmlNode
DeserializeXNode(string)
Deserializes the System.Xml.Linq.XNode from a JSON string.
public static XDocument DeserializeXNode(string value)
Parameters
value
string- The JSON string.
Returns
- 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.
public static XDocument DeserializeXNode(string value, string deserializeRootElementName)
Parameters
value
string- The JSON string.
deserializeRootElementName
string- The name of the root element to append when deserializing
Returns
- XDocument
- The deserialized XNode
GetSettingsCompact()
Gets the settings used by dynamicweb for compact json.
public static JsonSettings GetSettingsCompact()
Returns
- JsonSettings
- settings
GetSettingsHumanReadable()
Gets the settings used by dynamicweb for human readable json.
public static JsonSettings GetSettingsHumanReadable()
Returns
- JsonSettings
- settings
ParseArgumentsList(string)
public static List<object> ParseArgumentsList(string arguments)
Parameters
arguments
string
Returns
ParseArgumentsObject(string)
public static Dictionary<string, object> ParseArgumentsObject(string arguments)
Parameters
arguments
string
Returns
Serialize<T>(T)
Converts the object to a json string, using current settings.
public string Serialize<T>(T obj)
Parameters
obj
T- Object to serialize
Returns
- string
- jsonString
Type Parameters
T
- Type of object
Serialize<T>(T, JsonSettings)
Converts the object to a json string.
public static string Serialize<T>(T obj, JsonSettings settings)
Parameters
obj
T- Object to serialize
settings
JsonSettings- Settings for serialization
Returns
- string
- jsonString
Type Parameters
T
- Type of object