Skip to main content

Interface IUnitJsonConverter

Interface for Unit type JSON converters that handle serialization and deserialization

Assembly: MicroJson.dll​
View Source​
Declaration
public interface IUnitJsonConverter

Methods​

Serialize(object, bool)​

Serializes a Unit object to a JSON string

View Source​
Declaration
string? Serialize(object obj, bool convertNamesToCamelCase = true)
Returns​

System.String: A JSON string representing the Unit object, or null if the object is not a supported Unit type

Parameters​
TypeNameDescription
System.ObjectobjThe object to serialize
System.BooleanconvertNamesToCamelCaseWhether to convert property names to camel case

Deserialize<T>(string)​

Deserializes a JSON string to an object of type T

View Source​
Declaration
T? Deserialize<T>(string json)
Returns​

<T>: A deserialized object of type T, or default value if deserialization fails

Parameters​
TypeNameDescription
System.StringjsonThe JSON string to deserialize
Type Parameters​
NameDescription
TThe expected type (Unit type or array of Unit type)

Deserialize(string, Type)​

Deserializes a JSON string to an object of the specified type

View Source​
Declaration
object? Deserialize(string json, Type targetType)
Returns​

System.Object: A deserialized object, or null if deserialization fails

Parameters​
TypeNameDescription
System.StringjsonThe JSON string to deserialize
System.TypetargetTypeThe expected object type