I have a class that's currently inheriting from Dictionary and then adds a few first class member properties to it. Roughly:
public class Foo : Dictionary<string, string>
{
public string Bar { get; set; }
public string Baz { get; set; }
}
Upon serializing an instance of this object to JSON however, it appears that the serializer only emits the key/value pairings that I have stored within the Dictionary. Even if I apply DataMember attributes to the new 1st class properties, the JSON serializer doesn't appears to know what to do with these and instead just ignores them.
I'm assuming there's something fundamentally elementary that I'm missing, but scouring through code samples and docs on .net's JSON serializer, I've only found trivial examples that don't quite match what I'm doing. All our other classes that derive from some other base class don't appear to exhibit this problem, it's this one that derives from the Generic Dictionary in particular that is giving us fits.
[Edit] Short of moving a dictionary into Foo as a first class property, is there anyway to make this work? I'm assuming the hang up is that the serializer doesn't know what to "name" the dictionary to distinguish it from the other members?