1
我有一个json自定义转换器使用标准的asp.net库。 我的转换器看起来是这样的:嵌套json自定义转换器在C#与JavascriptConverter
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自定义转换器,但是我不知道在哪里插上
小增加:每个转换都会在'SupportedTypes'中返回它自己的类型。并非如初始文章所示 – Harry13 2016-09-05 13:20:34