0
我使用OpenRasta为我的.NET应用程序提供了一个API。OpenRasta AsJsonDataContract()字典
我使用Dictionaries时产生的JSON格式有问题。
我有以下配置:
ResourceSpace.Has.ResourcesOfType<Dictionary<String,String>>()
.AtUri("/test")
.HandledBy<ProductHandler>()
.AsXmlDataContract()
.And.AsJsonDataContract();
的ProductHandler返回以下解释:
Dictionary<String, String> dict = new Dictionary<string, string>();
dict.Add("foo1", "bar1");
dict.Add("foo2", "bar2");
dict.Add("foo3", "bar3");
我想下面的JSON:
{
"foo1": "bar1",
"foo2": "bar2",
"foo3": "bar3"
}
而是我得到如下:
[
{
"Key": "foo1",
"Value": "bar1"
},
{
"Key": "foo2",
"Value": "bar2"
},
{
"Key": "foo3",
"Value": "bar3"
}
]
任何建议如何解决这个问题?