We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class PublishSubmitModel: Convertible { var title = ""
var content = "" required init() {}
}
// 测试 let dic = [ "title": "", "content": nil ]
let model = dic.kj.model(PublishSubmitModel.self) Logger.info("content: \(model.content)")
model中的content 变为“nil” 字符串了
The text was updated successfully, but these errors were encountered:
在 func kj_modelValue(from jsonValue: Any?, _ property: Property) -> Any? { 方法中打印 Printing description of jsonValue: ▿ Optional
some : nil
func kj_modelValue(from jsonValue: Any?, _ property: Property) -> Any? {
guard jsonValue != nil, property.dataType == String.self else { return jsonValue } if let newJson = jsonValue as? Bool { return newJson == true ? "1" : "0" } if let newJson = jsonValue as? NSNumber { return newJson } guard let newJson = jsonValue as? String else { // 处理 string nil ;Optional<Any> - some : nil return "" } return newJson
} 做了一下处理能规避一下 不知道还有好点的方法不
Sorry, something went wrong.
No branches or pull requests
class PublishSubmitModel: Convertible {
var title = ""
}
// 测试
let dic = [
"title": "",
"content": nil
]
model中的content 变为“nil” 字符串了
The text was updated successfully, but these errors were encountered: