Storing JSON Dictionary Values into Variables
<p>Using a PHP file, I echoed data from a MySQL database in the following format: <code>[{"longitude":"-122.031","latitude":"37.3323”}]</code></p>

<p>In my Swift file, I use <code>NSJSONSerialization.JSONObjectWithData()</code> to create a JSON dictionary that looks like the following</p>

<pre><code>(

    {

        latitude = "37.3323";

        longitude = "-122.031";

    }

)
</code></pre>

<p>If I wanted to store the <strong>individual dictionary values</strong> inside variables, I believe the following snippet of Swift code would work</p>

<pre><code>class Location: NSObject {
    var latitude: String?
    var longitude: String?
}

var locations = [Location]()

if let locationDictionary = jsonDictionary["coordinates"] as? [String: AnyObject] {
        let location = Location()

        location.setValuesForKeysWithDictionary(locationDictionary)

        print(location.latitude, location.longitude)
}
</code></pre>

<p>The only problem I’m having is that I need my JSON dictionary to look like </p>

<pre><code>(

    coordinates =  {

        latitude = "37.3323";

        longitude = "-122.031";

    }

)
</code></pre>

<p>but I don’t know what steps to take to achieve this.</p>