Show / Hide Table of Contents

Class Json

Serializes and deserializes objects into and from JSON documents.

Inheritance
System.Object
Json
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Terrasoft.Common.Json
Assembly: Terrasoft.Common.dll
Syntax
public static class Json

Methods

Deserialize(String)

Deserializes the JSON to an object.

Declaration
public static object Deserialize(string value)
Parameters
Type Name Description
System.String value

The JSON string.

Returns
Type Description
System.Object

The deserialized object.

Deserialize(String, Type)

Deserializes the JSON to an object.

Declaration
public static object Deserialize(string value, Type type)
Parameters
Type Name Description
System.String value

The JSON string.

System.Type type

Type of the deserialized object.

Returns
Type Description
System.Object

The deserialized object.

Deserialize(String, Type, IList<JsonConverter>)

Deserializes the JSON to an object.

Declaration
public static object Deserialize(string value, Type type, IList<JsonConverter> converters)
Parameters
Type Name Description
System.String value

The JSON string.

System.Type type

Type of the deserialized object.

System.Collections.Generic.IList<Newtonsoft.Json.JsonConverter> converters

Json converters that will be used during serialization.

Returns
Type Description
System.Object

The deserialized object.

Deserialize<T>(String)

Deserializes the JSON to the specified type.

Declaration
public static T Deserialize<T>(string value)
Parameters
Type Name Description
System.String value

The JSON string.

Returns
Type Description
T

The deserialized object.

Type Parameters
Name Description
T

Deserialize<T>(String, JsonSerializerSettings)

Deserializes the JSON to the specified .NET type using Newtonsoft.Json.JsonSerializerSettings.

Declaration
public static T Deserialize<T>(string value, JsonSerializerSettings settings)
Parameters
Type Name Description
System.String value

The object to deserialize.

Newtonsoft.Json.JsonSerializerSettings settings

The Newtonsoft.Json.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.

DeserializeDictionary(String)

Declaration
public static Dictionary<string, string> DeserializeDictionary(string source)
Parameters
Type Name Description
System.String source
Returns
Type Description
System.Collections.Generic.Dictionary<System.String, System.String>

DeserializeJsonDate(String)

Deserializes json date.

Declaration
public static DateTime DeserializeJsonDate(string jsonDateTime)
Parameters
Type Name Description
System.String jsonDateTime

Json date time string.

Returns
Type Description
System.DateTime

Deserialized DateTime value.

DeserializeXmlNode(String)

Deserializes the XmlNode from a JSON string.

Declaration
public static XmlNode DeserializeXmlNode(string value)
Parameters
Type Name Description
System.String value

The JSON string.

Returns
Type Description
System.Xml.XmlNode

Instance of the System.Xml.XmlNode type.

FindPropertyByName(JObject, String)

Declaration
public static JProperty FindPropertyByName(this JObject source, string propertyName)
Parameters
Type Name Description
Newtonsoft.Json.Linq.JObject source
System.String propertyName
Returns
Type Description
Newtonsoft.Json.Linq.JProperty

FormatJsonString(String, Formatting)

Returns formatted JSON string.

Declaration
public static string FormatJsonString(string source, Formatting formatting)
Parameters
Type Name Description
System.String source

The JSON string.

Newtonsoft.Json.Formatting formatting

Formatting information.

Returns
Type Description
System.String

Formatted JSON string.

GetPropertyByName(JObject, String)

Declaration
public static JProperty GetPropertyByName(this JObject source, string propertyName)
Parameters
Type Name Description
Newtonsoft.Json.Linq.JObject source
System.String propertyName
Returns
Type Description
Newtonsoft.Json.Linq.JProperty

Serialize(Boolean)

Serializes the specified logical value and writes the JSON structure.

Declaration
public static string Serialize(bool obj)
Parameters
Type Name Description
System.Boolean obj

The logical value.

Returns
Type Description
System.String

The serialized object.

Serialize(Guid)

Serializes the specified unique identifier and writes the JSON structure.

Declaration
public static string Serialize(Guid obj)
Parameters
Type Name Description
System.Guid obj

The unique identifier.

Returns
Type Description
System.String

The serialized object.

Serialize(Int32)

Serializes the specified integer value and writes the JSON structure.

Declaration
public static string Serialize(int obj)
Parameters
Type Name Description
System.Int32 obj

The integer value.

Returns
Type Description
System.String

The serialized object.

Serialize(Object)

Serializes the specified object and writes the JSON structure.

Declaration
public static string Serialize(object obj)
Parameters
Type Name Description
System.Object obj

The object to serialize.

Returns
Type Description
System.String

The serialized object.

Serialize(Object, JsonConverter)

Serializes the specified object and writes the JSON structure.

Declaration
public static string Serialize(object obj, JsonConverter converter)
Parameters
Type Name Description
System.Object obj

The object to serialize.

Newtonsoft.Json.JsonConverter converter

Instance that converts an object to and from JSON.

Returns
Type Description
System.String

The serialized object.

Serialize(Object, Boolean)

Serializes the specified object and writes the JSON structure with quoteName flag.

Declaration
public static string Serialize(object obj, bool quoteName)
Parameters
Type Name Description
System.Object obj

The object to serialize.

System.Boolean quoteName

A value indicating whether object names will be surrounded with quotes.

Returns
Type Description
System.String

The serialized object.

Serialize(Object, Boolean, TypeNameHandling)

Serializes the specified object and writes the JSON structure with quoteName flag and specified type name handling.

Declaration
public static string Serialize(object obj, bool quoteName, TypeNameHandling typeNameHandling)
Parameters
Type Name Description
System.Object obj

The object to serialize.

System.Boolean quoteName

A value indicating whether object names will be surrounded with quotes.

Newtonsoft.Json.TypeNameHandling typeNameHandling

A value of Newtonsoft.Json.TypeNameHandling.

Returns
Type Description
System.String

The serialized object.

Serialize(String)

Serializes the specified string value and writes the JSON structure.

Declaration
public static string Serialize(string obj)
Parameters
Type Name Description
System.String obj

The string value.

Returns
Type Description
System.String

The serialized object.

Back to top Generated by DocFX