首页 > Web开发 > 详细

【KakaJSON手册】08-其他用法

时间:2019-08-23 15:18:45      阅读:175      评论:0      收藏:0      [点我收藏+]

除了完成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
}

【KakaJSON手册】08-其他用法

原文:https://www.cnblogs.com/mjios/p/11400008.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!