func convertValue()

in ios/Classes/ConfidenceFlutterSdkPlugin.swift [191:217]


func convertValue(_ type: String, _ value: Any) -> ConfidenceValue {
    switch type {
    case "bool":
        return ConfidenceValue.init(boolean: value as! Bool)
    case "double":
        return ConfidenceValue.init(double: value as! Double)
    case "int":
        return ConfidenceValue.init(integer: value as! Int)
    case "map":
        let dataMap = value as! Dictionary<String, Dictionary<String, Any>>
        let map: ConfidenceStruct = dataMap.mapValues { wrappedValue in
            let type = wrappedValue["type"] as! String
            return convertValue(type, wrappedValue["value"]!)
        }
        return ConfidenceValue.init(structure: map)
    case "list":
        let list = value as! [Dictionary<String, Any>]
        return ConfidenceValue.init(list: list.map { wrappedValue in
            let type = wrappedValue["type"] as! String
            return convertValue(type, wrappedValue["value"]!)
        })
    case "string":
        return ConfidenceValue.init(string: value as! String)
    default:
        return ConfidenceValue.init(integer: 0)
    }
}