Interface ISerialiser<TType>
Represents an interface for the serialisation of TType
Type Parameters
Name | Description |
---|---|
TType | The type of object to serialise |
Methods
FromJson(String, Action<ValidationContext<TType>>)
Deserialises a TType from a JSON string
Declaration
TType FromJson(string json, Action<ValidationContext<TType>> modifyContext = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | The JSON string |
System.Action<FluentValidation.ValidationContext<TType>> | modifyContext | Optional function to modify the context |
Returns
Type | Description |
---|---|
TType | The TType |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When |
ValidationException | Thrown when validation errors with the de-serialised TType |
Newtonsoft.Json.JsonException | Thrown when a the JSON fails to deserialise |
ToJObject(TType)
Serialises the TType to a JObject
Declaration
JObject ToJObject(TType obj)
Parameters
Type | Name | Description |
---|---|---|
TType | obj | The TType to serialise |
Returns
Type | Description |
---|---|
Newtonsoft.Json.Linq.JObject | JObject |
ToJson(TType)
Serialises the TType to a JSON UTF-8 string
Declaration
string ToJson(TType obj)
Parameters
Type | Name | Description |
---|---|---|
TType | obj | The TType to serialise |
Returns
Type | Description |
---|---|
System.String | A UTF-8 JSON string |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When |
Newtonsoft.Json.JsonException | Thrown when a the JSON fails to serialise |