我有一个django应用程序,它接受JSON请求,处理请求,将它们作为SOAP转发到API,处理响应,然后将响应作为JSON转发给客户端。
在响应中没有Iterable的方法工作正常。但对于具有Iterable的方法,它会返回一个混乱的响应或内部错误。
例如:
class MyCitiesIterable(ComplexModel):
__namespace__ = MY_NAMESPACE
ID = Integer
Description = String
class Other(ComplexModel):
__namespace__ = MY_NAMESPACE
Errors = Integer
class MyCitiesResponse(ComplexModel):
__namespace__ = MY_NAMESPACE
Cities = Iterable(MyCitiesIterable)
Other = Other
返回对象:
(MyCitiesResponse){
Cities =
(MyCityArray){
MyCity[] =
(MyCity){
Description = "City 1"
ID = 1
},
(MyCity){
Description = "City 2"
ID = 2
},
(MyCity){
Description = "City 3"
ID = 3
},
}
Other =
(Other){
Errors = 0
}
}
JSON回复
{ "Cities":
[
{
"Description": "MyCity",
"ID": [[["Description", "City 1"],
["ID", 1]],
[["Description", "City 2"],
["ID", 2]],
[["Description", "City 3"],
["ID", 3]]]}],
"Other": {"Errors": 0}
}
]
}