HandyJSON icon indicating copy to clipboard operation
HandyJSON copied to clipboard

Calling the toJSONString method with UIColor.clear will result in an error

Open jijiucheng opened this issue 1 year ago • 0 comments

Question

Calling toJSONString after creating an object with the UIColor.clear property reports an error and fails to serialize successfully.

Code

class SandBoxModel: HandyJSON {
    var mode: Int = 0
    var color: UIColor = .clear
    
    func mapping(mapper: HelpingMapper) {
        mapper <<<
            color <-- HexColorTransform()
    }
    
    public required init() {}
}

var model = SandBoxModel()
model.color = .clear
if let jsonString = model.toJSONString {
    print(jsonString)
}

Error

Swift/ContiguousArrayBuffer.swift:580: Fatal error: Index out of range

jijiucheng avatar Jun 28 '23 03:06 jijiucheng