JSON Serialization helper class that uses JSON.NET. This class serializes JSON to and from string and files on disk.
Westwind.Utilities.JsonSerializationUtils
public static class JsonSerializationUtils : object
Remarks
JSON.NET is loaded dynamically at runtime to avoid hard linking the Newtonsoft.Json.dll to Westwind.Utilities. Just make sure that your project includes a reference to JSON.NET when using this class.
Class Members
Member | Description | |
---|---|---|
CreateJsonNet |
Dynamically creates an instance of JSON.NET public static JsonSerializer CreateJsonNet(bool throwExceptions, bool camelCase) |
|
Deserialize |
Deserializes an object, array or value from JSON string to an object or value public static object Deserialize(string jsonText, Type type, bool throwExceptions) |
|
Deserialize |
Deserializes an object, array or value from JSON string to an object or value public static T Deserialize |
|
DeserializeFromFile |
Deserializes an object from file and returns a reference. public static object DeserializeFromFile(string fileName, Type objectType, bool throwExceptions) |
|
DeserializeFromFile |
Deserializes an object from file and returns a reference. public static T DeserializeFromFile |
|
FormatJsonString |
Takes a single line JSON string and pretty formats it using indented formatting. public static string FormatJsonString(string json) |
|
Serialize |
Serializes an object to an XML string. Unlike the other SerializeObject overloads this methods returns a string rather than a bool result! public static string Serialize(object value, bool throwExceptions, bool formatJsonOutput, bool camelCase) |
|
SerializeToFile |
Serializes an object instance to a JSON file. public static bool SerializeToFile(object value, string fileName, bool throwExceptions, bool formatJsonOutput, bool camelCase) |
Requirements
Namespace: Westwind.UtilitiesAssembly: westwind.utilities.dll
© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic