且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

迅速如何检查来自Json的NULL值

更新时间:2023-11-29 08:12:58

您只需要有条件地将字典值强制转换为String,并在出现故障null的情况下使用Nil合并运算符??分配"0":

You just need to conditionally cast your dictionary value to String and use the Nil Coalescing Operator ?? to assign "0" in case of failure null:

let vote_status = Stream["vote_status"] as? String ?? "0"