title: How to save an array as a json file in Swift?
body: <p>I'm new at swift and I'm having trouble with this. so what i need to do is save this array as a json file in the document folder of the iphone.</p>
  
  <pre><code>var levels = ["unlocked", "locked", "locked"]
  </code></pre>
  
  <p>and then later on be able to read it back into another array. Could someone please tell me how to do this? or provided with the exact code to accomplish this.</p>
  
  <p>EDITED:
  I found one example of this. This is how they set up the data:</p>
  
  <pre><code> "[ {"person": {"name":"Dani","age":"24"}}, {"person": {"name":"ray","age":"70"}} ]" 
  </code></pre>
  
  <p>and the you can access it this way:</p>
  
  <pre><code> if let item = json[0] 
     { if let person = item["person"] 
       { if let age = person["age"] 
        { println(age) } } }
  </code></pre>
  
  <p>But I need to be able to do the same but from a file that is saved on the document folder.</p>