I am trying to decode a JSON like this one with Himotoki in Swift 3
next: [
{
question: 'Fréquence',
condition: { '==': ['answer', 'Actions'] },
},
{
question: 'Fréquence',
condition: { '>=': ['answer', 'Stop'] },
},
{
question: 'Risque',
condition: { '<=': ['answer', 'nul'] }
}
]
In the condition, there is an object that looks like a dictionary, since the field name changes ('==', '<=', '>=, ...). The value is then an array of string
I have tried to decode like this
typealias ConditionType = [String]
extension ConditionType: Decodable {}
struct NextItem {
let question: String?
let condition: [String : ConditionType]?
}
extension NextItem: Decodable {
static func decode(_ e: Extractor) throws -> NextItem {
return try NextItem(
question: e <|? "question",
condition: e <|-|? "condition"
)
}
}
I do not not how to decode the ConditionType since there is no field name for the array
I am trying to decode a JSON like this one with Himotoki in Swift 3
In the condition, there is an object that looks like a dictionary, since the field name changes ('==', '<=', '>=, ...). The value is then an array of string
I have tried to decode like this
I do not not how to decode the ConditionType since there is no field name for the array