Custom base Newtonsoft.Json.JsonConverter
to filter serialized properties.
More...
Inherits JsonConverter.
Public Member Functions | |
override bool | CanConvert (Type objectType) |
Determine if the object type is T . More... | |
override object | ReadJson (JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) |
Read the specified properties to the object. More... | |
override void | WriteJson (JsonWriter writer, object value, JsonSerializer serializer) |
Write the specified properties of the object. More... | |
Protected Member Functions | |
abstract string[] | GetPropertyNames () |
Get the property names to serialize, only used once when initializing. More... | |
virtual T | CreateInstance () |
Create the instance for ReadJson() to populate. More... | |
Custom base Newtonsoft.Json.JsonConverter
to filter serialized properties.
Useful for Unity or 3rd party classes, since we can't insert any Newtonsoft.Json.JsonIgnoreAttribute
. By the way, this works by reflection to access properties. Please make sure your property not to be stripped by Unity.
It's very easy to make a custom converter, just inherit and override GetPropertyNames()
as the filter:
T | The value type. |
|
protectedpure virtual |
Get the property names to serialize, only used once when initializing.
Implemented in BoundsConverter, Matrix4x4Converter, ColorConverter, QuaternionConverter, RectConverter, RectOffsetConverter, Vector2Converter, Vector3Converter, and Vector4Converter.
|
protectedvirtual |
Create the instance for ReadJson()
to populate.
override bool CanConvert | ( | Type | objectType | ) |
Determine if the object type is T
.
objectType | Type of the object. |
true
if this can convert the specified type; otherwise, false
.override object ReadJson | ( | JsonReader | reader, |
Type | objectType, | ||
object | existingValue, | ||
JsonSerializer | serializer | ||
) |
Read the specified properties to the object.
reader | The Newtonsoft.Json.JsonReader to read from. |
objectType | Type of the object. |
existingValue | The existing value of object being read. |
serializer | The calling serializer. |
override void WriteJson | ( | JsonWriter | writer, |
object | value, | ||
JsonSerializer | serializer | ||
) |
Write the specified properties of the object.
writer | The Newtonsoft.Json.JsonWriter to write to. |
value | The value. |
serializer | The calling serializer. |