无法下标"JSON"类型的值,索引类型为"STRING"

Wor*_*ing 8 swifty-json swift3

这是在Swift2中工作但现在在Swift3中(自动转换后)我收到一个错误:

if self.entry["scheduler"] || self.entry["owner"]

Cannot subscript a value of type 'JSON' with an index of type 'STRING'

self.entry ["scheduler"]等的值是布尔值,但我认为问题是索引,"调度程序"和"所有者"

当然,我self.entry以完全相同的方式引用其他索引,并在构建时不会出错.

xcode自动更新,我生活在一场噩梦中.

Dav*_*idA 14

替换.string前两行中您期望的任何类型

let scheduler = self.entry["scheduler"].string
let owner = self.entry["owner"].string

if(scheduler != nil || owner != nil)
{
    // Take care here - scheduler and owner are both optionals
}
Run Code Online (Sandbox Code Playgroud)