让说我有一个来自同一AJAX调用根据传入的参数返回以下2个JSON对象可与2种不同的数据类型,同一属性的JSON对象以相同的反序列化调用反序列化?
第一个返回的孩子属性的字符串数组:
{
parent: {
child: [
"item 1",
"item 2",
"item 3",
]
}
}
,第二个用于返回子属性的对象数组:
{
parent: {
child: [
{
"attribute1": "Attribute 1",
"attribute2": "Attribute 2",
"attribute3": "Attribute 3"
},
{
"attribute1": "Attribute 1",
"attribute2": "Attribute 2",
"attribute3": "Attribute 3"
},
{
"attribute1": "Attribute 1",
"attribute2": "Attribute 2",
"attribute3": "Attribute 3"
},
]
}
}
是否有可能反序列化任一成相同的模型不知何故?也许那里有孩子(如ChildString & ChildObject)被相应地填充这取决于型2个不同的属性?
我目前使用Jil的反序列化,但我对其他人开放如果需要的话。
谢谢!
请参阅http://michaelcummings.net/mathoms/using-a-custom-jsonconverter-to-fix-bad-json-results/ – jmoreno