【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
}