Interface IJsonSerializer
Provides functionality to serialize objects or value types to JSON and to deserialize JSON into objects or value types.
Namespace: Umbraco.Cms.Core.Serialization
Assembly: Umbraco.Core.dll
Syntax
public interface IJsonSerializer
Methods
View SourceDeserialize<T>(string)
Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.
Declaration
T? Deserialize<T>(string input)
Parameters
| Type | Name | Description |
|---|---|---|
| string | input | The JSON input to parse. |
Returns
| Type | Description |
|---|---|
| T | A |
Type Parameters
| Name | Description |
|---|---|
| T | The target type of the JSON value. |
Serialize(object?)
Converts the specified input into a JSON string.
Declaration
string Serialize(object? input)
Parameters
| Type | Name | Description |
|---|---|---|
| object | input | The input. |
Returns
| Type | Description |
|---|---|
| string | A JSON string representation of the value. |
TryDeserialize<T>(object, out T?)
Attempts to parse an object that represents a JSON structure - i.e. a JSON object or a JSON array - to a strongly typed representation.
Declaration
bool TryDeserialize<T>(object input, out T? value) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| object | input | The object input to parse. |
| T | value | The parsed result, or null if the parsing fails. |
Returns
| Type | Description |
|---|---|
| bool | True if the parsing results in a non-null value, false otherwise. |
Type Parameters
| Name | Description |
|---|---|
| T | The target type of the JSON value. |