V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
CommandZi
V2EX  ›  iDev

SamllJSONParser - 一个小巧的基于 Swift 4.2 写的 JSON 解析库

  •  
  •   CommandZi · 2018-09-13 10:02:48 +08:00 · 2569 次点击
    这是一个创建于 2023 天前的主题,其中的信息可能已经有所发展或是发生改变。

    昨晚边看苹果发布会直播,边敲出来。基于 Swift 4.2 的 Dynamic Member Lookup 特性。

    特点上一段代码一目了然,一共就 200 多行代码。

    let string = "{\"id\": 923, \"name\": \"hello\"}"
    let json = JSON.parse(string: string)
    let id = json.id.intValue    //   923
    let name: String = json.name    //   hello
    

    嗯,一点点 Python 的味道。 思路来自 Introduce User-defined "Dynamic Member Lookup" Types 。 另外还有一个 dynamicCallable 特性处于 Coming soon,值得期待

    欢迎提 Issue、Star、Fork。地址 SmallJSONParser

    agagega
        1
    agagega  
       2018-09-13 16:23:03 +08:00
    我怎么感觉像是 JavaScript 的味道
    CommandZi
        2
    CommandZi  
    OP
       2018-09-13 17:53:58 +08:00
    @agagega 是的,就是类似动态类型语言
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3231 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:16 · PVG 20:16 · LAX 05:16 · JFK 08:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.