OpenRasta を使用して、.NET アプリケーション用の API を提供しています。
辞書を使用するときに生成される 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"
}
]
これを修正する方法はありますか?