intsig171 / SmartCodable

SmartCodable is a data parsing library based on Codable. It is simple to use, with robust compatibility being one of its main features. SmartCodable 是基于Codable实现的数据解析库。简单易用,强悍的兼容性是SmartCodable的主要特点。 表层API和功能几乎和HandyJSON一致,支持快速的迁移。
https://smart-codable.vercel.app
MIT License
412 stars 43 forks source link

兼容类String型时 int值为1时解析不出来 #13

Closed wangyuchaogeek closed 7 months ago

wangyuchaogeek commented 7 months ago
 // demo中的代码
    let dict = [
        "string1": 1, //解析不出来!!
        "string2": 345.0,
        "string3": [],
        "string4": NSNull()
    ] as [String : Any]

    guard let feed = CompatibleString.deserialize(from: dict) else { return }
    print("string1的值为", feed.string1)
    print("string2的值为", feed.string2)
    print("string3的值为", feed.string3)
    print("string4的值为", feed.string4 ?? "")
intsig171 commented 7 months ago

V3.2.2 已发布。 String类型遇到Int数据进行兼容的时候,由于Int和Bool都是NSNumber,1也可以as Bool,因此被忽略。