I have a class as follows:
public class Usage
{
public string app { get; set; }
public Dictionary<string, string> KVPs { get; set; }
}
When I use this code:
var json = new JavaScriptSerializer().Serialize(usage);
it gives me this JSON:
{"app":"myapp", "KVPs":{"k1":"v1", "k2":"v2"}}
I'd like it to return something like this instead:
{"app":"myapp", "k1":"v1", "k2":"v2"}
Is there a way to do this? I am currently using the JavaScriptSerializer
. If there is a way to do this using JSON.Net, I would be willing to switch to that.