There is a child class from DynamicObject, when trying to serialize using JSON.NET, the output is an empty object. What can you do about it? Using ExpandoObject is not an option, since access to the "fields" by key.
public class DataObject : DynamicObject { public IDictionary<string, object> Values; public DataObject(IDictionary<string, object> values) { Values = values; } public override bool TryGetMember(GetMemberBinder binder, out object result) { if (Values.ContainsKey(binder.Name)) { result = Values[binder.Name]; return true; } result = null; return false; } } PS An example of how I try to serialize:
File.WriteAllText("test.json", JsonConvert.SerializeObject(obj)); The object is a complex graph of quite impressive size.