How to access a link embedded in a JSON dictionary using AlamoFire/ ObjectMapper?
<p>This is the objectmapper I'm using: </p>

<p><a href="https://github.com/Hearst-DD/ObjectMapper" rel="nofollow noreferrer">ObjectMapper</a>  /  <a href="https://github.com/tristanhimmelman/AlamofireObjectMapper" rel="nofollow noreferrer">AlamoFireObjctMapper</a></p>

<p>Here is the JSON data I'm working with, I'm trying to access the "link" value:</p>

<pre><code>channels =     (
  {
    social =             {
      facebook =                 {
        "facebook_id" = 47360808996;
        link = "https://www.facebook.com/CBS";
      };
      twitter =                 {
        link = "https://twitter.com/CBS";
        "twitter_id" = 97739866;
      }
    }
  }
)
</code></pre>

<p>I've created custom objects to represent each level of the JSON dictionary:</p>

<pre><code>class SocialInfo: Mappable {

  var channels: Social?

  required init?(map: Map) {
  }

  func mapping(map: Map) {

    channels &lt;- map["channels"]

  }
}

class Social: Mappable {

  var facebookSocial: Facebook?
  var twitterSocial: Twitter?


  required init?(map: Map) {
  }

  func mapping(map: Map) {

     facebookSocial &lt;- map["facebook"]
     twitterSocial &lt;- map["twitter"]

  }

}


class Facebook: Mappable {

  var facebookLink: NSURL?

  required init?(map: Map) {
  }

  func mapping(map: Map) {

    facebookLink &lt;- (map["link"], URLTransform())

  }
}
</code></pre>

<p>Initialy I had the "facebookLink" under the "Facebook" class as a string but it kept returing nil.  I then tried the URLTransform to change it to a type of NSURL but now it's throwing the error:</p>

<blockquote>
  <p>Type of expression is ambiguous without more context</p>
</blockquote>

<p>Here is how I'm trying to retrieve the JSON data:</p>

<pre><code> func getSocialInfo (completionHandler: @escaping (SocialInfo?, Error?) -&gt; ()){

    Alamofire.request("\(baseURL)/\(apiKey)/show/950", method: .get, encoding: JSONEncoding.default).validate ()
      .responseObject{  (response: DataResponse&lt;SocialInfo&gt;) in

        switch response.result {
        case .success:
          let socialInfo = response.result.value

          print("This is the social info: \(socialInfo?.channels?.facebookSocial?.facebookLink)")


          completionHandler(socialInfo!, nil)

        case .failure(let error):

          print("Sorry there was an error: \(error)")
          completionHandler(nil,error)
          return
        }

  }
}
</code></pre>