title: Best practice to find out if SwiftyJSON dictionary has key
body: <p>I'm trying to find a way to get the value of a key in a <a href="https://github.com/SwiftyJSON/SwiftyJSON" rel="noreferrer">SwiftyJSON</a> dictionary and return a default string, if the key is not set. The following example works fine, but I'm not really satisfied. Do you know a more elegant way?</p>
  <h3>Example:</h3>
  <pre><code>let users: JSON = [
      [&quot;id&quot;: 1, &quot;name&quot;: &quot;one&quot;],
      [&quot;id&quot;: 2],
      [&quot;id&quot;: 3, &quot;name&quot;: &quot;three&quot;]
  ]
      
  for (key: String, user: JSON) in users {      
      println(user.object.objectForKey(&quot;name&quot;) != nil
          ? user[&quot;name&quot;].stringValue
          : &quot;default&quot;)
  }
  </code></pre>