序列化一个自定义Key的Date类型
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
想实现一个类型为Date, 在类中的字段名为date, json中的字段名为my_date的功能,我试了好多种办法都没能达到要求,目前版本支持么?
代码如下:
class ExtendType: HandyJSON {
var date: Date?
var decimal: NSDecimalNumber?
var url: URL?
var data: Data?
var color: UIColor?
func mapping(mapper: HelpingMapper) {
mapper.specify(property: &date, name: "my_date")
mapper <<<
date <-- CustomDateFormatTransform(formatString: "yyyy-MM-dd")
}
public required init() {}
}
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue provides an ExtendType example using HelpingMapper, property mapping, and CustomDateFormatTransform. Start by reviewing how HandyJSON handles custom property names and Date transforms, then verify whether the shown mapping produces the requested JSON field name and date format. The issue names no files or tests, so the completion check is not otherwise specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100