【KakaJSON手册】08_其他用法


除了完成JSON和Model的转换之外,KakaJSON内部还有很多实用的功能,有些也开放为public接口了

遍历属性

struct Cat {
    var age: Int = 0
    let name: String = ""
}

guard let type = Metadata.type(Cat.self) as? ModelType,
    let properties = type.properties else { return }

for property in properties {
    print(property.name,
          property.type,
          property.isVar,
          property.ownerType,
          property.offset)
    // age Int true Cat 0
    // name String false Cat 8
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM