alibaba / alibaba/HandyJSON

Object properties returning nil with mappers

Open
#391 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

I have this code below
```Swift
import Foundation
import HandyJSON

class SignedS3URL: BaseModel {
var uploadUrl:UploadURLDetails?
var isPublic:Bool?
var filename:String?
var url:String?
var s3Key:String?
}

class Fields: BaseModel {
var x_amz_algorithm:String?
var policy:String?
var acl:String?
var content_type:String?
var x_amz_signature:String?
var x_amz_credential:String?
var x_amz_date:String?
var x_amz_meta_videoid:String?
var x_amz_security_token:String?
var key:String?

required init() {}

func mapping(mapper: HelpingMapper) {
mapper <<<
self.x_amz_algorithm <-- "x-amz-algorithm"
mapper <<<
self.content_type <-- "Content-Type"
mapper <<<
self.x_amz_signature <-- "x-amz-signature"
mapper <<<
self.x_amz_credential <-- "x-amz-credential"
mapper <<<
self.x_amz_date <-- "x-amz-date"
mapper <<<
self.x_amz_meta_videoid <-- "x-amz-meta-videoid"
mapper <<<
self.x_amz_security_token <-- "x-amz-security-token"
}
}

class UploadURLDetails: BaseModel {
var url:String?
var fields:Fields?
}
```

but values in mapper returns nil, any help or suggextion?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported nil values with the SignedS3URL, UploadURLDetails, and Fields models, then inspect Fields.mapping(mapper:) and the HandyJSON mapping behavior. Confirm which mapped properties are populated and document the input and expected values needed to define the fix.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.