美文网首页
Swift 字符串数组转json

Swift 字符串数组转json

作者: 艾欧尼亚 | 来源:发表于2020-07-09 19:58 被阅读0次
    let array = [ "one", "two" ]
    func notPrettyString(from object: Any) -> String? {
        if let objectData = try? JSONSerialization.data(withJSONObject: object, options: JSONSerialization.WritingOptions(rawValue: 0)) {
            let objectString = String(data: objectData, encoding: .utf8)
            return objectString
        }
        return nil
    }
    

    相关文章

      网友评论

          本文标题:Swift 字符串数组转json

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