Class JsonSerializer
Provides JSON serialization and deserialization using System.Text.Json.
Implements
Inherited Members
Namespace: Innovt.Core.Serialization
Assembly: Innovt.Core.dll
Syntax
public class JsonSerializer : ISerializer
Constructors
| Edit this page View SourceJsonSerializer(bool, bool, bool, IList<JsonConverter>)
Initializes a new instance of the JsonSerializer class with specified options.
Declaration
public JsonSerializer(bool ignoreNullValues = true, bool ignoreReadOnlyProperties = true, bool propertyNameCaseInsensitive = true, IList<JsonConverter> converters = null)
Parameters
Type | Name | Description |
---|---|---|
bool | ignoreNullValues | Indicates whether null values should be ignored during serialization. |
bool | ignoreReadOnlyProperties | Indicates whether read-only properties should be ignored during serialization. |
bool | propertyNameCaseInsensitive | Indicates whether property name casing should be treated as case-insensitive. |
IList<JsonConverter> | converters | A list of custom JSON converters to be used during serialization and deserialization. |
Methods
| Edit this page View SourceDeserializeObject<T>(string)
Deserializes a JSON string into an object of type T
.
Declaration
public T DeserializeObject<T>(string serializedObject)
Parameters
Type | Name | Description |
---|---|---|
string | serializedObject | The JSON string to deserialize. |
Returns
Type | Description |
---|---|
T | The deserialized object of type |
Type Parameters
Name | Description |
---|---|
T | The type of object to deserialize. |
SerializeObject<T>(T)
Serializes an object of type T
into a JSON string.
Declaration
public string SerializeObject<T>(T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj | The object to serialize. |
Returns
Type | Description |
---|---|
string | The serialized object as a JSON string. |
Type Parameters
Name | Description |
---|---|
T | The type of object to serialize. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |