How to use fastJSON (or some other JSON lib, possibly) to dump some data into a dictionary format, e.g. {"key1": "valstring", "key2": 1234}
?
If I try to dump Dictionary<string, Object>
I get something like [{"k":"key1","v":"valstring"},{"k":"key2","v":1234}]
instead.
We use Json.NET at our office. We send json objects between python and C#. We ran into the same problem, though ours was just the differences in how the languages naturally serialized it.
The best part about it, if I'm remember correctly, is that it had this behavior right out of the box.
var dict = new Dictionary<string, string>();
dict.Add("key", "val");
dict.Add("key2", "val2");
string json = JsonConvert.SerializeObject(dict);
Json should equal { "key": "val", "key2": "val2" }