Json 作为请求主体的Swift结构

Json 作为请求主体的Swift结构,json,swift,postgresql,vapor,decodable,Json,Swift,Postgresql,Vapor,Decodable,尝试使用Vapor和Swift将数据发送到我的postgreSQL数据库 下面是示例代码(Swift结构作为请求主体) 但我面临着下一个错误: keyNotFound(编码键(stringValue:“id”,intValue:nil),Swift.DecodingError.Context(编码路径:[],调试描述:“否 与键编码键关联的值(stringValue:“id\”,intValue: nil)(“id\”,underyingerror:nil)) 此行上已修复错误: let tod

尝试使用Vapor和Swift将数据发送到我的postgreSQL数据库

下面是示例代码(Swift结构作为请求主体)

但我面临着下一个错误:

keyNotFound(编码键(stringValue:“id”,intValue:nil),Swift.DecodingError.Context(编码路径:[],调试描述:“否 与键编码键关联的值(stringValue:“id\”,intValue: nil)(“id\”,underyingerror:nil))

此行上已修复错误:

let todoItemModel = try JSONDecoder().decode(ToDoResponseModel.self, from: data)
蒸汽送我:

[错误]DecodingError.keyNotFound:键“IsComplete”所需的值。(国际货币基金组织,swift:26)


看起来您正在从客户端发送
isComplete
,但是Vapor服务器正在等待
isComplete
(大写字母I)

您是否检查了
数据
是否包含
isComplete
的密钥对?
let todoItemModel = try JSONDecoder().decode(ToDoResponseModel.self, from: data)