I have a local JSON file like follows.How to extract all the value of coordinates and store in arrays?Thank you!
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[144.3429008,-38.17437148]
},
"properties":{
"name":"Wilson Road"
},
{
"type":"Feature",
"geometry":
{"type":"Point",
"coordinates":[145.1801783,-37.6602503]
},"
properties":{
"name":"Wilson Road"
}
.......
I have tried
let path = Bundle.main.path(forResource: "json", ofType: "json")
let jsonData=NSData(contentsOfFile: path!)
do {
let parsedData = try JSONSerialization.jsonObject(with: jsonData! as Data, options:[]) as! [String:AnyObject]
let features = parsedData["features"] as! NSArray
print(features)
}catch{}
The output is
( ......
{
geometry = {
coordinates = (
"144.3429008",
"-38.17437148"
);
type = Point;
};
......
What is the next step?