c# - Couchbase custom deserialization -


i have class need serialize json in couchbase in custom manner. like:

var converters = new[] { new customconverter() }; var json = jsonconvert.serializeobject(myobject, jsonconverters.toarray());  var result = _couchbaseclient.executestore(storemode.add, id, json); 

but how can deserialize again, using customconverter? want retrieve json , deserializing myself. realize there's executeget method, i'd work via view.

is possible?

i've tried add converter jsonconvert.defaultsettings doesn't seem use it. keep getting jsonserializationexception. i'm guessing couchbase resets settings, or uses own.

digging couchbase code, found it. couchbase has extension methods use own settings. can see on github:

public static class couchbaseclientextensions {     public static jsonserializersettings jsonserializersettings;      static couchbaseclientextensions()     {         jsonserializersettings = new jsonserializersettings             {                 contractresolver = new documentidcontractresolver()             };     }      // ...      private static string serializeobject(object value)     {         var json = jsonconvert.serializeobject(value,                                 formatting.none,                                 jsonserializersettings);         return json;     } } 

so can add own converters this:

foreach (var jsonconverter in jsonconverters) {     if (!couchbaseclientextensions              .jsonserializersettings              .converters.any(x => x.gettype() == jsonconverter.gettype()))     {         couchbaseclientextensions             .jsonserializersettings             .converters.add(jsonconverter);     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -