title: How to parse JSON in Swift 2?
body: <p>I have a PHP web api that returns json in the following format:</p>
  
  <pre><code>{"users":[
     {"user": {id:"1","name":"ahmad"}},
     ...
  
  ]}
  </code></pre>
  
  <p>In my Swift 2 code, I am able to retrieve the data above store it in an <code>NSArray</code> named <code>users</code></p>
  
  <p>Now, I need to iterate throw each <code>user</code> to convert it into an object:</p>
  
  <pre><code>for user in users {
      print("found: \(user)")
  }
  </code></pre>
  
  <p>That ouputs something like:</p>
  
  <pre><code>found: {
      user =     {
          id = 1;
          name = ahmad;
      };
  }
  </code></pre>
  
  <p>but when I try to access any element of that object I get an error:</p>
  
  <pre><code>let id  = user["user"]["id"]     //does not work: Xcode wont compile
  let id2 = user["user"]!["id"]!   //does not work: Xcode wont compile
  let id3 = user!["user"]!["id"]!  //does not work: Xcode wont compile
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FEzfI.png" alt="enter image description here">
  Then I tried :</p>
  
  <pre><code>if let u=user["user"] {     //does not work: Xcode wont compile
      // do somthing
  }
  </code></pre>
  
  <p>I put a break point at <code>print("\(user)")</code> to see what is going on, and here is what I found:</p>
  
  <p><img src="https://i.stack.imgur.com/I5VwS.png" alt="enter image description here"></p>
  
  <p>When I print the description of each individual <code>user</code> I get:
  <img src="https://i.stack.imgur.com/FBBTo.png" alt="enter image description here"></p>
  
  <p>How can I access the elements of this JSON data in Swift 2?</p>