I'm using Swift 5 and I'm trying to create a struct to hold the contents of an Google Sheets API Call. I'm stuck with "values" key which values i want to fetch, change to Int type and store at separate array variable which i can use lately.
Here's one result from the API:
{
"range": "Sheet1!A2:B4",
"majorDimension": "ROWS",
"values": [
[
"-10",
"12"
],
[
"-9",
"-15"
],
[
"-8",
"-9"
]
[
"-7",
"4"
]
]
}
In my previous approaches i got an error: "Expected to decode String but found an array instead."
So my question is how should inner structure for "values" looks to finished the task?
struct Sheet: Decodable {
let range: String?
let majorDimension: String?
let values: [Values]?
}
do {
let json = try JSONDecoder().decode(Sheet.self, from: data)
} catch let error {
print(error as Any)
}
Thanks!