Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 1.04 KB

custom-serializers.md

File metadata and controls

9 lines (6 loc) · 1.04 KB

Custom JSON Serializers

The Couchbase SDK uses Newtonsoft's Json.Net as its default JSON serializer. If you are using a custom serializer, there are some special requirements which must be met to support Linq2Couchbase.

Custom serializers are used by creating a class which implements the ITypeSerializer interface, and including it in the SDK configuration. However, to support Linq2Couchbase, instead the serializer should extend IExtendedTypeSerializer. This interface provides a key additional feature.

The GetMemberName method is used to determine how a particular member property of a POCO will be written as JSON to the document in Couchbase. This is important, because the N1QL query must reference member names in the way they appear in Couchbase, not the way they appear in your .Net POCOs.

Here is an example of how this method was implemented for Newtonsoft's Json.Net.