using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
""a"" : { ""3847"" : ""fizz"" },
""b"" : { ""2409"" : ""bang"" },
""c"" : { ""9031"" : ""pow"" },
var obj = JsonConvert.DeserializeObject<Bar>(json);
foreach(var kvp in obj.MyFooDictionary)
Console.WriteLine(kvp.Key + ": " + kvp.Value.Id + " " + kvp.Value.Name);
[JsonProperty(ItemConverterType=typeof(FooConverter))]
public Dictionary<string, Foo> MyFooDictionary { get; set; }
public int Id { get; set; }
public string Name { get; set; }
class FooConverter : JsonConverter
public override bool CanConvert(Type objectType)
return objectType == typeof(Foo);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
JObject obj = JObject.Load(reader);
JProperty prop = obj.Properties().First();
return new Foo { Id = int.Parse(prop.Name), Name = (string)prop.Value };
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
throw new NotImplementedException();