【发布时间】:2016-11-07 16:43:09
【问题描述】:
我们的团队已选择Couchbase 作为我们应用程序的缓存。我们在这个缓存中存储的对象是这样的
public class CatalogEntity
{
public int Id { get; set; }
public string Name { get; set; }
// this property gives us trouble
public Hashtable Attributes { get; set;}
}
在我们的代码中,从 CouchBase 缓存中检索对象后,我发现主要类型(Id 和 Name)的属性已正确反序列化,但 Hashtable 类型的 Attributes 未反序列化并且保持为 JSON。例如,如果我有类似的东西
var entity = new CatalogEntity();
entity.Attributes["foo"] = new Foo();
缓存中的对象将具有Attributes["foo"] 属性作为Foo 类的JSON 表示。
我想知道如何正确序列化/反序列化 Hashtable 类型?我应该将对象序列化为二进制,而是将二进制流存储在 CouchBase 中吗?
【问题讨论】: