alibaba / alibaba/HandyJSON

自定义解析路径和自定义解析过程结合使用

Open
#414 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.3k
Forks
677
PR merge metrics
No merged PRs in 30d

Description

使用场景,服务器端返回的数据字段关键字,数据又是加密的情况
class SchemeCaseDetailInfoModel: HandyJSON {
required init() {}

var desc : String?

func mapping(mapper: HelpingMapper) {
mapper <<<
self.desc <-- ("description",TransformOf(fromJSON: { (rawString: String?) -> String? in
if let value = rawString {
if !value.isEmpty {
return String.base64Decoding(value) // base64解码
}
}
return nil
}, toJSON: { (rawString: String?) -> String? in
if let value = rawString {
if !value.isEmpty {
return String.base64Encoding(value)
}
}
return nil
}))
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the mapping(mapper:) entry point in the SchemeCaseDetailInfoModel example and inspect how the custom path and TransformOf are represented. Confirm the intended combined usage and define completion as a supported, documented or tested way to apply both to the same field.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.