Class JsonSerializer
Serializes and deserializes objects and types to and from JSON structures.
Inheritance
Inherited Members
Namespace: Manatee.Json.Serialization
Assembly: Manatee.Json.dll
Syntax
public class JsonSerializer
Properties
| Improve this Doc View SourceAbstractionMap
Gets or sets the abstraction map used by this serializer.
Declaration
public AbstractionMap AbstractionMap { get; set; }
Property Value
Type | Description |
---|---|
AbstractionMap |
Options
Gets or sets a set of options for this serializer.
Declaration
public JsonSerializerOptions Options { get; set; }
Property Value
Type | Description |
---|---|
JsonSerializerOptions |
Methods
| Improve this Doc View SourceDeserialize(Type, JsonValue)
Deserializes a JSON structure to an object of the appropriate type.
Declaration
public object? Deserialize(Type type, JsonValue json)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the object that the JSON structure represents. |
JsonValue | json | The JSON representation of the object. |
Returns
Type | Description |
---|---|
System.Nullable<System.Object> | The deserialized object. |
Exceptions
Type | Condition |
---|---|
TypeDoesNotContainPropertyException | Optionally thrown during automatic deserialization when the JSON contains a property which is not defined by the requested type. |
Deserialize<T>(JsonValue)
Deserializes a JSON structure to an object of the appropriate type.
Declaration
public T Deserialize<T>(JsonValue json)
Parameters
Type | Name | Description |
---|---|---|
JsonValue | json | The JSON representation of the object. |
Returns
Type | Description |
---|---|
T | The deserialized object. |
Type Parameters
Name | Description |
---|---|
T | The type of the object that the JSON structure represents. |
Exceptions
Type | Condition |
---|---|
TypeDoesNotContainPropertyException | Optionally thrown during automatic deserialization when the JSON contains a property which is not defined by the requested type. |
DeserializeType<T>(JsonValue)
Deserializes a JSON structure to the public static properties of a type.
Declaration
public void DeserializeType<T>(JsonValue json)
Parameters
Type | Name | Description |
---|---|---|
JsonValue | json | The JSON representation of the type. |
Type Parameters
Name | Description |
---|---|
T | The type to deserialize. |
Exceptions
Type | Condition |
---|---|
TypeDoesNotContainPropertyException | Optionally thrown during automatic deserialization when the JSON contains a property which is not defined by the requested type. |
GenerateTemplate<T>()
Generates a template JSON inserting default values.
Declaration
public JsonValue GenerateTemplate<T>()
Returns
Type | Description |
---|---|
JsonValue |
Type Parameters
Name | Description |
---|---|
T |
Serialize(Type, Object)
Serializes an object to a JSON structure.
Declaration
public JsonValue Serialize(Type type, object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the object to serialize. |
System.Object | obj | The object to serialize. |
Returns
Type | Description |
---|---|
JsonValue | The JSON representation of the object. |
Serialize<T>(T)
Serializes an object to a JSON structure.
Declaration
public JsonValue Serialize<T>(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to serialize. |
Returns
Type | Description |
---|---|
JsonValue | The JSON representation of the object. |
Type Parameters
Name | Description |
---|---|
T | The type of the object to serialize. |
SerializeType<T>()
Serializes the public static properties of a type to a JSON structure.
Declaration
public JsonValue SerializeType<T>()
Returns
Type | Description |
---|---|
JsonValue | The JSON representation of the type. |
Type Parameters
Name | Description |
---|---|
T | The type to serialize. |