0

我有一个 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}
        }
    ]
}
4

0 回答 0