How can I decode the following using swift Decodable? I'm only interested in the extract value
{
"batchcomplete":"",
"query":{
"normalized":[ ],
"pages":{
"434325":{ //can be any number!
"pageid":434325,
"ns":0,
"title":"asdfasdfsa",
"extract":""
I'm attempting the following:
struct Entry: Decodable {
let batchcomplete: String
let query: Query
struct Query: Decodable {
let normalized: [String]
let pages: Page
struct Page: Decodable {
let pageid: Entry // I think this is going to be an issue
struct Entry: Decodable {
let title: String
let extract: String
}
}
}
}
I'm trying to retrieve the extract like this:
print(entry.query.pages.first.extract)
Is there a way to use .first for this ?
I'm only every going to get maximum one page so ideally I would just grab the first element.