Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow Serializer Customization #10

Closed
wants to merge 1 commit into from

2 participants

Brian Chavez Jeffry Morris
Brian Chavez

Hi there,

I have some custom serialization requirements; however, currently the CouchbaseClientExtensions does not allow me to customize the Newtonsoft.Json serializer.

This patch allows serializer customization by placeing a static field onCouchbaseClientExtensions.JsonSerializerSettings that enables users of the couchbase extension class to customize the serializer.

Also added a static constructor to CouchbaseClientExtensions which maintains defaults.

Thanks,
Brian

Jeffry Morris
Collaborator

Hi bchavez -

Thanks for the submission!

We require contributors to sign a Contributor License Agreement (CLA), can you create an account and sign our CLA?

Just follow these steps:

1-http://review.couchbase.org
2-Login in and select your username on the top right hand side and then "settings"
3-The last item on the left in the settings view is an "Agreements" menu tab, select that an then
select the "New Contributor Agreement"

Thanks,

Jeff

Brian Chavez

Hi Jeff, I already did. It's the same bchavez that submitted this bug report:

https://www.couchbase.com/issues/browse/NCBC-352

Thanks,
Brian

Jeffry Morris
Collaborator

Thanks Brian! I'll try to push this into the 1.3.1 release the first week of January assuming it passes code review and regression testing, etc.

Jeffry Morris
Collaborator

This is scheduled for 1.3.2 release, you can track progress here: http://www.couchbase.com/issues/browse/NCBC-358

Thanks for the submission,

-Jeff

Brian Chavez bchavez closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2013
  1. Brian Chavez
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/Couchbase/Extensions/CouchbaseClientExtensions.cs
21 src/Couchbase/Extensions/CouchbaseClientExtensions.cs
View
@@ -15,7 +15,17 @@
namespace Couchbase.Extensions
{
public static class CouchbaseClientExtensions
- {
+ {
+ public static JsonSerializerSettings JsonSerializerSettings;
+
+ static CouchbaseClientExtensions()
+ {
+ JsonSerializerSettings = new JsonSerializerSettings
+ {
+ ContractResolver = new DocumentIdContractResolver()
+ };
+ }
+
private const string Null = "null";
#region No expiry
@@ -138,13 +148,10 @@ private static T DeserializeObject<T>(string key, string value)
}
private static string SerializeObject(object value)
- {
- var json = JsonConvert.SerializeObject(value,
+ {
+ var json = JsonConvert.SerializeObject(value,
Formatting.None,
- new JsonSerializerSettings
- {
- ContractResolver = new DocumentIdContractResolver()
- });
+ JsonSerializerSettings);
return json;
}
Something went wrong with that request. Please try again.