alibaba / alibaba/HandyJSON

5.0.0 mapping(mapper:HelpingMapper)自定义解析规则为nil

Open
#347 1 comment 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 XPUser: XPBaseUser {

var uid:String?
var headImage:String?
/// 区域
var addrArea:String?
/// 俱乐部
var club:String?
/// 修改类型{1头像,2昵称,3手机号,4区域,5俱乐部,6密码}
var updateType:Int?
/// <#变量说明#>
var slt:String?
/// 是否是会员
var isVip:Bool?
/// 会员过期时间
var vipExpire:String?

//如果不适用接口的字段名,需要特定字段使用下面这个方法替换
func mapping(mapper: HelpingMapper) {
mapper <<<
self.uid <-- "id"
// mapper <<<
// self.loginName <-- "account"
// mapper <<<
// self.headImgUrl <-- "headImage"
// mapper <<<
// self.nickName <-- "nickname"
// mapper <<<
// self.thirdLoginType <-- "otherType"
// mapper <<<
// self.thirdLoginAccount <-- "otherAccount"
}
}`

`//通用的用户对象
class XPBaseUser: XPBaseModel {
var token:String?

var userID:String?
var loginName:String?
var password:String?
var headImgUrl:String?
var name:String?
var nickName:String?
var gender:Int = 0 //0女1男
var email:String?
var mobile:String?
var telephone:String?
var qq:String?
var weixin:String?
var weibo:String?

var validateCode:String?

var thirdLoginType:String? //1.微信,2.微博,3.QQ
var thirdLoginAccount:String?
var thirdLoginNickName:String?
var thirdLoginHeadImgUrl:String?
}`

`import HandyJSON

class XPBaseModel: HandyJSON {

var deviceType:Int = 1;
var deviceUid:String = pp_DeviceUUID
var ipAddress:String = XPIPAddress.shared.publicIP

required init(){}
}`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported nil custom mapping rule with the XPUser, XPBaseUser, and XPBaseModel definitions shown in the issue. Trace HandyJSON's mapping and inheritance handling to identify where the rule becomes nil; done means the provided custom uid-to-id mapping behaves consistently with the other inherited properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.