I am using OpenRasta provide an API for my .NET application.
I have a problem with the format of the JSON it produces when using Dictionaries.
I have the following config:
ResourceSpace.Has.ResourcesOfType<Dictionary<String,String>>()
.AtUri("/test")
.HandledBy<ProductHandler>()
.AsXmlDataContract()
.And.AsJsonDataContract();
The ProductHandler returns the following Dictionary:
Dictionary<String, String> dict = new Dictionary<string, string>();
dict.Add("foo1", "bar1");
dict.Add("foo2", "bar2");
dict.Add("foo3", "bar3");
I would like the following JSON:
{
"foo1": "bar1",
"foo2": "bar2",
"foo3": "bar3"
}
But instead I get the following:
[
{
"Key": "foo1",
"Value": "bar1"
},
{
"Key": "foo2",
"Value": "bar2"
},
{
"Key": "foo3",
"Value": "bar3"
}
]
Any suggestions how to fix this?