美文网首页
swift 的字典在xcode中直接打印

swift 的字典在xcode中直接打印

作者: 简书_旋 | 来源:发表于2018-09-03 23:23 被阅读0次

swift 的字典在xcode中直接打印看起来很费劲 我只想要json 原始的样子

写一个分类就ok了 

下面这段直接粘贴然后 对字典和数组 po 调这个方法就Ok 了 

extension Dictionary {

    func jsonPrint() {

        let ff =try! JSONSerialization.data(withJSONObject:self, options: [])

        let str =String(data:ff, encoding: .utf8)

        print(str!)

    }

}

extension Array {

    func jsonPrint() {

        let ff =try! JSONSerialization.data(withJSONObject:self, options: [])

        let str =String(data:ff, encoding: .utf8)

        print(str!)

    }

}

相关文章

网友评论

      本文标题:swift 的字典在xcode中直接打印

      本文链接:https://www.haomeiwen.com/subject/gydwwftx.html