I would like to decode this JSON using codingkeys
and decoder
methods in my Swift code. I would rather just create two data models : Photos
that contains the page information and the array of type Photo
and not have to create another type.
I tried different methods given online but couldn't get it to work for this scenario. Can I do this short of doing it manually? My response is decoded automatically on Alamofire side and I would love to keep it that way.
{
"photos":
{
"page": 1,
"pages": 2234,
"perpage": 1,
"total": 223368,
"photo":
[
{
"id": "51854706028",
"owner": "193539154@N05",
"secret": "c09e67936d",
"server": "65535",
"farm": 66,
"title": "Window",
"ispublic": 1,
"isfriend": 0,
"isfamily": 0
}
]
},
"stat": "ok"
}