How can i decode the following json-array (which is part of a http-request)
[
{ "id": 0, "name": "darth maul" },
{ "id": 1, "name": "darth sidious" }
]
in swift vapor 3 with the decode function?
vapor code:
struct User: Content {
var id: Int
var name: String
}
router.put("user") { request -> Future<HTTPStatus> in
return try request.content.decode(User.self).map({ (user) -> (HTTPStatus) in
// process ...
return .ok
})
}