Skip to main content

Class MicroJson

JSON Serialization and Deserialization library for .NET

Assembly: MicroJson.dll
View Source
Declaration
public static class MicroJson

Methods

Deserialize(string)

Desrializes a Json string into an object.

View Source
Declaration
public static object? Deserialize(string json)
Returns

System.Object: An ArrayList, a Hashtable, a double, a long, a string, null, true, or false

Parameters
TypeName
System.Stringjson

DeserializeString(string)

Deserializes a Json string into an object.

View Source
Declaration
public static object? DeserializeString(string json)
Returns

System.Object: An ArrayList, a Hashtable, a double, a long, a string, null, true, or false

Parameters
TypeName
System.Stringjson

EscapeString(string)

Escapes special characters in a string to ensure it is JSON-compliant.

View Source
Declaration
public static string EscapeString(string value)
Returns

System.String: The escaped string with special characters properly encoded.

Parameters
TypeNameDescription
System.StringvalueThe string to escape.

Serialize(object, DateTimeFormat, bool)

Converts an object to a JSON string.

View Source
Declaration
public static string? Serialize(object o, MicroJson.DateTimeFormat dateTimeFormat = DateTimeFormat.ISO8601, bool convertNamesToCamelCase = true)
Returns

System.String: The JSON object as a string or null when the value type is not supported.

Parameters
TypeNameDescription
System.ObjectoThe value to convert.
Meadow.Foundation.Serialization.MicroJson.DateTimeFormatdateTimeFormatThe format to use for DateTime values. Defaults to ISO 8601 format.
System.BooleanconvertNamesToCamelCaseTrue to convert all properties to camel case during serialization

SerializeString(string)

Safely serialize a String into a JSON string value, escaping all backslash and quote characters.

View Source
Declaration
public static string SerializeString(string input)
Returns

System.String: The serialized JSON string.

Parameters
TypeNameDescription
System.StringinputThe string to serialize.

DeserializeList<T>(ArrayList)

Deserializes a JSON array into a list of objects of type T.

View Source
Declaration
public static List<T> DeserializeList<T>(ArrayList array) where T : new()
Returns

System.Collections.Generic.List<<T>>: A list of objects of type T.

Parameters
TypeNameDescription
System.Collections.ArrayListarrayThe JSON array to deserialize.
Type Parameters
NameDescription
TThe type of objects in the list.

DeserializeArray<T>(ArrayList)

Deserializes a JSON array into an array of objects of type T.

View Source
Declaration
public static T[] DeserializeArray<T>(ArrayList array) where T : new()
Returns

<T>[]: An array of objects of type T.

Parameters
TypeNameDescription
System.Collections.ArrayListarrayThe JSON array to deserialize.
Type Parameters
NameDescription
TThe type of objects in the array.

Deserialize<T>(byte[])

Deserializes an object of type T from a JSON string.

View Source
Declaration
public static T Deserialize<T>(byte[] encodedData)
Returns

<T>: An object of type T.

Parameters
TypeNameDescription
System.Byte[]encodedDataA UTF8-encoded JSON string to deserialize.
Type Parameters
NameDescription
TThe type of object to deserialize.

Deserialize<T>(string)

Deserializes an object of type T from a JSON string.

View Source
Declaration
public static T Deserialize<T>(string json)
Returns

<T>: An object of type T.

Parameters
TypeNameDescription
System.StringjsonThe JSON string to deserialize.
Type Parameters
NameDescription
TThe type of object to deserialize.

Deserialize(string, Type)

Deserializes an object of type T from a JSON string.

View Source
Declaration
public static object Deserialize(string json, Type type)
Returns

System.Object: An object of the specified type

Parameters
TypeNameDescription
System.StringjsonThe JSON string to deserialize.
System.TypetypeThe type of object to deserialize.