IJsonConverter

Namespace: SnowBank.Data.Json · interface

Base non-generic interface for IJsonConverter implementations

Methods

BindJsonValue

object BindJsonValue(JsonValue value, ICrystalJsonTypeResolver resolver)

Binds a JSON value into the corresponding CLR type

For best performance, prefer using the Unpack method on the generic IJsonConverter interface, if this converter implements it!

GetDefinition

CrystalJsonTypeDefinition GetDefinition()

Returns the definition metadata for the type handled by this converter

GetTargetType

Type GetTargetType()

Type of the instances that are compatible with this converter

Serialize

void Serialize(object value, Type declaringType, Type runtimeType, CrystalJsonWriter writer)

Untyped visitor that can serialize instances of the supported type

  • value — Value to serialize
  • declaringType — Type has declared in the parent type (ex: type of the member that contains this value, which could be abstract)
  • runtimeType — Actual type of the value at runtime
  • writer — Output where the instances will be written to

TryMapMemberToPropertyName

bool TryMapMemberToPropertyName(string memberName, out string propertyName)

Returns the JSON property name for the corresponding member of the target type of this converter

  • memberName — Name of the member of the target type of this converter, as in the ".NET" name for the property of field.
  • propertyName — Receives the corresponding name of the property, as found in the JSON serialized form.

Returns: true if a member with this name exists in the target type of this converter; otherwise, false

TryMapPropertyToMemberName

bool TryMapPropertyToMemberName(string propertyName, out string memberName)

Returns the member name in the target type of this converter for the corresponding JSON property

  • propertyName — Name of the property, as found in the JSON serialized form.
  • memberName — Name of the corresponding member of the target type of this converter, as in the ".NET" name for the property of field.

Returns: true if the property name matches a member in the target type of this converter; otherwise, false