如何解决这个问题:vapor receive response property output format is changed?

问题描述 投票:0回答:0

我想使用内容结构来解码响应,但在某些情况下输出属性是:

"output": [
    {
        "file": "aaa.jpg"
    }
],

有些案例的输出属性是:

"output": "aaa.jpg"

我该怎么做?

struct ReplicateModelData: Codable {
  let output: String?
}

try response.content.decode(ReplicateModelData.self)

输出类型变了,不能每次都解码成功

vapor
© www.soinside.com 2019 - 2024. All rights reserved.