Skip to content

当 Class 中包含闭包属性时,mapper 中标记忽略 Exclud 该属性,在序列化 toJson() 中无效 #505

@Mervin1024

Description

@Mervin1024

示例代码:

class AAA: HandyJSON {
    var a = "a"
    var b = 1
    var c = false
    var p1: (() -> Void)?

    required init() {}
    
    func mapping(mapper: HelpingMapper) {
        mapper >>> self.p1
    }
}

使用示例:

        let a = AAA()
        a.p1 = {
            let a = 1+1
        }
        let json = a.toJSONString()

此时在 _ExtendCustomModelType.swift 文件中 line:243 。if mapper.propertyExcluded(key: Int(bitPattern: info.address)) 判断条件为 false。原因是 address 对应不上

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions