我有一个使用标准 asp.net 库的 json 自定义转换器。我的转换器如下所示:
public class MyObjectToJson : JavaScriptConverter
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
MyObject TheObject = obj as MyObject;
Dictionary<string, object> OutputJson = new Dictionary<string, object>();
OutputJson.Add("SomeProperty", TheObject.Property1);
//line that I'm not figuring out
//I have a type MyNestedObject nested in the object model of MyObject
//I added that nested converter in the SupportedTypes method
OutputJson.Add("TheNestedObject",....?);
return OutputJson;
}
public override IEnumerable<Type> SupportedTypes
{
get { return new Type[] { typeof(MyObject), typeof(MyNestedObject) }; }
}
基本上,我有另一个名为 MyNestedObjectJson 的 json 自定义转换器,但我想知道在哪里插入它。