.Net SDK 2.2.5 Dictionary<string,string> Convert error

.net

#1

save UPPER KEY Dictionary
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add(“AAA”, “BBB”);
bucket.Upsert(“TTT33”, dic);
then getData
var result44 = bucket.Get<Dictionary<string, string>>(“TTT33”);

result is

aaa BBB Not AAA BBB
IS default json convertError


#2

@edobnet

I think the behavior you are seeing is a result of the default behavior for Json.net serialization in Couchbase. The behavior is to use the CamelCasePropertyNamesContractResolver. This contract resolver attempts to convert property names to camel case (starting with lower case), and dictionary string keys are treated as property names by Json.net.

One fix for this would be to change the serializer to not have this configuration. Here is an example of how to configure this:

var config = new ClientConfiguration{
    Serializer = ()=>new DefaultSerializer(new JsonSerializerSettings(), new JsonSerializerSettings())
};

Brant


#3

thank you
but I Hope You Change int Base/Default Version
In What Out What
otherelse many people will In Wrong


#4

@edobnet

Unfortunately, I don’t think it would be possible to change the default. This would cause lots of backwards compatibility problems for all of the other users.

Brant