qq_22555381 2015-07-15 11:10 采纳率: 0%
浏览 1518
已采纳

IOS swift 字符串解析成NSArry类型

[{"Android":[{"ID":31,"TN":"天天","Date":"2015-03-17","Des":"315活动"},{"ID":32,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":33,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":34,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":35,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":36,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":38,"TN":"天天","Date":"2015-03-17","Des":"315"},{"ID":22,"TN":"天天","Date":"2015-01-31","Des":"sdaSDASD"},{"ID":23,"TN":"天天","Date":"2015-01-31","Des":"fgsdfgsdfg"},{"ID":7,"TN":"天天","Date":"2015-01-17","Des":"课外活动"},{"ID":8,"TN":"天天","Date":"2015-01-17","Des":"sun sun"},{"ID":9,"TN":"天天","Date":"2015-01-17","Des":"美不胜收,应接不暇"},{"ID":11,"TN":"天天","Date":"2015-01-17","Des":"fgsdjfgsdgfb"},{"ID":12,"TN":"天天","Date":"2015-01-17","Des":"frvxfsdds"},{"ID":13,"TN":"天天","Date":"2015-01-17","Des":"hahahahahhh"},{"ID":14,"TN":"天天","Date":"2015-01-17","Des":"盛开的菊花"},{"ID":15,"TN":"天天","Date":"2015-01-17","Des":"灯塔"},{"ID":16,"TN":"天天","Date":"2015-01-17","Des":"八仙花"},{"ID":18,"TN":"天天","Date":"2015-01-17","Des":"郁金香"},{"ID":19,"TN":"天天","Date":"2015-01-17","Des":"企鹅"},{"ID":20,"TN":"天天","Date":"2015-01-17","Des":"沙漠"},{"ID":21,"TN":"天天","Date":"2015-01-17","Des":"水母"},{"ID":3,"TN":"天天","Date":"2015-01-07","Des":"cvxcvxzcvcvzxcvzzcccccccccccccccc"},{"ID":4,"TN":"天天","Date":"2015-01-07","Des":"dfsadfsadfdfsdfsd"}]}]
这个NSString数据类型的字符串如何转换成一个NSArry数组?在安卓中是通过getJSONbject("Android")解析出来的

  • 写回答

4条回答 默认 最新

  • sun_ljz 2015-07-16 01:22
    关注

    最后输出的就是NSArray

             let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
            if data != nil {
                let obj: AnyObject? =  NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil)
                if obj!.isKindOfClass(NSArray.classForCoder()) {
                    print(obj)
                }
    
            }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 爬虫预算充足,跪巨佬
  • ¥15 滑块验证码拖动问题悬赏
  • ¥15 Wanted but not invoked:Actually, there were zero interactions with this moc
  • ¥20 怎么驱动tb6612
  • ¥15 Arcgis 3D效果点要素
  • ¥15 在执行yolo训练脚本的时候,没有报错,在扫描val这一步后就推出执行了
  • ¥15 delphi开发的WEBSERVER改用HTTPS协议
  • ¥15 pic16f877A单片机的计数器proteus仿真失效
  • ¥100 调查 Vitis AI 中验证 .xmodel 量化后的正确性
  • ¥30 codelite全屏时file、setting那一行消失了