ObjectMapper icon indicating copy to clipboard operation
ObjectMapper copied to clipboard

how convenient to NSCoding?

Open FunnyerFeng opened this issue 4 years ago • 0 comments

Your JSON dictionary:

{
  "name": "ObjectMapper",
  "url": "https://github.com/Hearst-DD/ObjectMapper"
}

Your model:

struct Repo: Mappable {
  var name: String!
  var url: URL!

  init(_ map: Map) {
    name <- map["name"]
    url <- map["url"]
  }
}

What you did:

let repo = Mapper<Repo>().map(myJSONDictionary)

What you expected:

I exepected something like:

Repo(name: "ObjectMapper", url: "https://github.com/Hearst-DD/ObjectMapper")

What you got:

Repo(name: "ObjectMapper", url: nil)  // expected the url is mapped correctly

FunnyerFeng avatar Apr 22 '20 11:04 FunnyerFeng