Add support for custom serialization representations using toSerializedValue/fromSerializedValue.