I'm trying to get values from this JSON. This is part of the JSON because the real JSON data is too long.
"hits" : [ {
"recipe" : {
"uri" : "http://www.edamam.com/ontologies/edamam.owl#recipe_bd8def1d09d8c308f659e6945f366271",
"label" : "Pinchos de carne",
"image" : "http://img.recetascomidas.com/recetas/640_480/pinchos-de-carne.jpg",
"source" : "Recetal Comidas",
"url" : "http://pinchos-de-carne.recetascomidas.com/",
"shareAs" : "http://www.edamam.com/recipe/pinchos-de-carne-bd8def1d09d8c308f659e6945f366271/carne",
"yield" : 6.0,
"dietLabels" : [ "Low-Carb" ],
"healthLabels" : [ "Dairy-Free", "Gluten-Free", "Egg-Free", "Peanut-Free", "Tree-Nut-Free", "Soy-Free", "Fish-Free", "Shellfish-Free" ],
"cautions" : [ ],
"ingredientLines" : [ "600 gr. de carne magra de cerdo", "2 cucharadas de pimentón dulce", "1 cucharada de pimentón picante", "1 cucharada de cúrcuma", "1 cucharada de sazonador especial para carnes", "3 cucharadas de perejil fresco bien picadito", "1/2 cucharada de comino", "Aceite de oliva", "3 patatas", "1 diente de ajo", "Pimienta negra", "Sal" ],
"ingredients" : [ {
"text" : "600 gr. de carne magra de cerdo",
"quantity" : 600.0,
"measure" : null,
"food" : "carne magra cerdo",
"weight" : 600.0
}, {
"text" : "2 cucharadas de pimentón dulce",
"quantity" : 2.0,
"measure" : "tbsp",
"food" : "pimenton dulce",
"weight" : 13.6
}, {
"text" : "1 cucharada de pimentón picante",
"quantity" : 1.0,
"measure" : "tbsp",
"food" : "pimenton picante",
"weight" : 6.8
}, {
"text" : "1 cucharada de cúrcuma",
"quantity" : 1.0,
"measure" : "tbsp",
"food" : "curcuma",
"weight" : 6.8
}, {
"text" : "1 cucharada de sazonador especial para carnes",
"quantity" : 1.0,
"measure" : "tbsp",
"food" : "sazonador",
"weight" : 2.7
}, {
"text" : "3 cucharadas de perejil fresco bien picadito",
"quantity" : 3.0,
"measure" : "tbsp",
"food" : "perejil fresco",
"weight" : 11.4
}, {
"text" : "1/2 cucharada de comino",
"quantity" : 0.5,
"measure" : "tbsp",
"food" : "comino",
"weight" : 3.0
}, {
"text" : "Aceite de oliva",
"quantity" : 2.0,
"measure" : "tbsp",
"food" : "aceite oliva",
"weight" : 27.0
}, {
"text" : "3 patatas",
"quantity" : 3.0,
"measure" : null,
"food" : "patatas",
"weight" : 195.0
}, {
"text" : "1 diente de ajo",
"quantity" : 1.0,
"measure" : null,
"food" : "ajo",
"weight" : 3.0
}, {
"text" : "Pimienta negra",
"quantity" : 1.0,
"measure" : "peppercorn",
"food" : "pimienta negra",
"weight" : 0.3
}, {
"text" : "Sal",
"quantity" : 0.0,
"measure" : null,
"food" : "sal",
"weight" : 3.3346887
} ]
For example, I want to get label values that is inside "recipe". I successfully print in console all the JSON, but I don't know how to get recipe values.
I hope you can help me.
This is the code I have now.
let url: String = "https://test-es.edamam.com/search?q=pollo"
var arregloHits: NSMutableArray = []
override func viewDidLoad() {
super.viewDidLoad()
pruebaJson()
}
func pruebaJson(){
if ControladorService.conexionInternet(){
ControladorService.sharedInstance.callUrlWithCompletion(url: url, params: nil, completion: { (finished, response) in
if finished{
let result = NSMutableArray(array: response["hits"] as! NSArray)
self.arregloHits = result
print(self.arregloHits)
}else{
print("Connection failed")
}
}, method: .get)
}else{
print("No Internet")
}
}
Your top level json structure is a dictionary. So you need to parse it into [String: Any]. Then your hints level is a JSON array, so you need to parse it into [Any]
Here is an example. Don't forget to handle unwrap
do{
let json = try JSONSerialization.jsonObject(with: yourJSONData, options: []) as? [String: Any]
let hits = json?["hits"] as? [Any]
dump(hits)
}catch let error{
}
Related
So the JSON variable let json = JSON(nearbyChargingSites.jsonString!) contains the current data.:
{
"timestamp" : 1626902257093,
"superchargers" : [
{
"location" : {
"lat" : 63.325319,
"long" : 10.305137
},
"total_stalls" : 19,
"distance_miles" : 10.064082000000001,
"type" : "supercharger",
"site_closed" : false,
"available_stalls" : 15,
"name" : "Leinstrand, Norway - Klett"
},
{
"location" : {
"lat" : 63.466445999999998,
"long" : 10.91766
},
"total_stalls" : 16,
"distance_miles" : 11.838984999999999,
"type" : "supercharger",
"site_closed" : false,
"available_stalls" : 16,
"name" : "Stjørdal, Norway"
},
{
"location" : {
"lat" : 63.734355000000001,
"long" : 11.281487
},
"total_stalls" : 12,
"distance_miles" : 31.206503999999999,
"type" : "supercharger",
"site_closed" : false,
"available_stalls" : 11,
"name" : "Levanger, Norway"
},
{
"location" : {
"lat" : 62.832030000000003,
"long" : 10.009639999999999
},
"total_stalls" : 20,
"distance_miles" : 44.117753,
"type" : "supercharger",
"site_closed" : false,
"available_stalls" : 17,
"name" : "Berkåk, Norway"
}
],
"congestion_sync_time_utc_secs" : 1626902199,
"destination_charging" : [
{
"distance_miles" : 23.366278999999999,
"name" : "Bårdshaug Herregård",
"location" : {
"lat" : 63.299208,
"long" : 9.8448650000000004
},
"type" : "destination"
},
{
"distance_miles" : 38.390034,
"name" : "Fosen Fjordhotel",
"location" : {
"lat" : 63.959356999999997,
"long" : 10.223908
},
"type" : "destination"
},
{
"distance_miles" : 46.220022999999998,
"name" : "Falksenteret",
"location" : {
"lat" : 63.293301999999997,
"long" : 9.0834460000000004
},
"type" : "destination"
},
{
"distance_miles" : 54.981445000000001,
"name" : "Væktarstua",
"location" : {
"lat" : 62.908683000000003,
"long" : 11.893306000000001
},
"type" : "destination"
}
]
}
I use SwiftyJSON and tries to get the superchargers latitude, longitude and name, like this:
let jsonName = json["superchargers"]["name"]
let jsonLat = json["superchargers"]["location"]["lat"]
let jsonLong = json["superchargers"]["location"]["long"]
When trying to print any of those, all of them return nil.
Any ideas what I am doing wrong, and how to do this?
The reason I want to do this is because I want to add them as annotation to a MKMapView.
The first error is that the JSON initializer you are using will create a single JSON string object, it will not parse the string as JSON data:
Instead of:
let json = JSON(nearbyChargingSites.jsonString!)
you need to use:
let json = JSON(data: dataFromJSONString)
Second you need to iterate over the superchargers array to collect all the values
Try something like:
if let dataFromString = nearbyChargingSites.jsonString!.data(using: .utf8, allowLossyConversion: false) {
let json = try! JSON(data: dataFromString,options: .allowFragments)
for supercharger in json["superchargers"].arrayValue {
let jsonName = supercharger["name"].stringValue
let jsonLat = supercharger["location"]["lat"].doubleValue
let jsonLong = supercharger["location"]["long"].doubleValue
}
}
Please note that the above code does not perform error handling and will crash if values are missing from JSON.
I'm able to run an aggregate MongoDb (3.8) request in the mongo shell but I can't get it out working using the java driver (3.4 java 8).
here's the input source structure. I want to aggregate informations to provide company activities stats. note that the ape document states for the company registered activity. I want to group on the first 3 digits of the ape code
{
"_id" : "00552017600016",
"sirene" : "005520176",
"nic" : "00016",
"natureCode" : "5710",
"natureLabel" : "SAS, société par actions simplifiée",
"name" : "HERNAS CARTONNAGE",
"brand" : "",
"registerDate" : ISODate("1954-12-31T23:00:00Z"),
"startDate" : ISODate("1954-12-31T23:00:00Z"),
"headquaters" : true,
"address" : {
"number" : 50,
"ext" : null,
"lane" : "RUE PASTEUR",
"zipcode" : "80210",
"city" : "FEUQUIERES EN VIMEU",
"country" : "FRANCE",
"location" : {
"type" : "Point",
"coordinates" : [
1.60319694244078,
50.0537636973407
],
"accuracy" : 0,
"ban" : "ADRNIVX_0000000260779642"
}
},
"ape" : {
"code" : "1721A",
"label" : "Fabrication de carton ondulé"
},
"staff" : {
"count" : 50,
"year" : 2016
}
}
running this commands in the shell works like a charm
db.companies_geo.aggregate([ {$match:{"address.city":"LE MANS"}},
{$group:{_id:{$substrBytes:["$ape.code",0,2]}, count:{$sum:1}, code:{$last:"$ape.code"}, label:{$last:"$ape.label"}}},
{$project:{count:1, code:1, label:1}},
{$sort:{count:-1}},
{$limit:20}
])
it produces this result
{ "_id" : "68", "count" : 4603, "code" : "6832B", "label" : "Supports juridiques de gestion de patrimoine immobilier" }
{ "_id" : "47", "count" : 1929, "code" : "4799B", "label" : "Vente par automate, aut. com. dét. hors mag., éventaire ou marché" }
{ "_id" : "94", "count" : 1874, "code" : "9499Z", "label" : "Autres organisations fonctionnant par adhésion volontaire" }
{ "_id" : "86", "count" : 1704, "code" : "8690F", "label" : "Activités de santé humaine non classées ailleurs" }
{ "_id" : "56", "count" : 832, "code" : "5630Z", "label" : "Débits de boissons" }
{ "_id" : "90", "count" : 816, "code" : "9004Z", "label" : "Gestion de salles de spectacles" }
{ "_id" : "85", "count" : 769, "code" : "8560Z", "label" : "Activités de soutien à l'enseignement" }
{ "_id" : "70", "count" : 592, "code" : "7022Z", "label" : "Conseil pour les affaires et autres conseils de gestion" }
{ "_id" : "96", "count" : 585, "code" : "9609Z", "label" : "Autres services personnels n.c.a." }
{ "_id" : "81", "count" : 582, "code" : "8130Z", "label" : "Services d'aménagement paysager" }
on the java side I've tried this but the code line bellow the while iteration raises the exception org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.BsonField.
private List<Document> cityActivityGraph() {
Bson filter = Filters.eq("address.city", "LE MANS");
BsonField id = new BsonField("_id", Filters.eq(new Document("$substrBytes", Arrays.asList("$ape.code", 0, 2))));
BsonField count = Accumulators.sum("count", 1);
BsonField label = Accumulators.last("ape.label", 1);
BsonField code = Accumulators.last("ape.code", 1);
Bson group = Aggregates.group(id, count, code, label);
Bson match = Aggregates.match(filter);
Bson projections = Projections.include("code", "label", "count");
Bson project = Aggregates.project(projections);
Bson sort = Sorts.descending("count");
MongoCursor<Document> cursor = getTable().aggregate(Arrays.asList(
Aggregates.match(match),
Aggregates.group(group),
Aggregates.project(project),
Aggregates.sort(sort))).iterator(); <--- exception here
List<Document> result = new ArrayList<>();
while (cursor.hasNext()) {
Document doc = cursor.next();
System.out.println(doc.toJson());
result.add(doc);
}
return result;
}
any idea ? thanks in advance
found a solution, perhaps not the most efficient but it works
Bson id = new Document("_id", new Document("$substrBytes", Arrays.asList("$ape.code", 0, 3)));
BsonField code = Accumulators.last("code", "$ape.code");
BsonField label = Accumulators.last("label", "$ape.label");
BsonField count = Accumulators.sum("count", 1);
Bson projections = Projections.include("code", "label", "count");
Bson sort = Sorts.descending("count");
AggregateIterable<Document> stats = getTable().aggregate(Arrays.asList(
Aggregates.match(filter),
Aggregates.group(id, code, label, count),
Aggregates.project(projections),
Aggregates.limit(limit),
Aggregates.sort(sort)
));
List<Document> result = new ArrayList<>();
for (Document d:stats) {
result.add(d);
}
return result;
I'm trying to update 8 locations at a time in Firebase, using the Swift SDK. Somehow I managed to update the first two, but the other six only writes to the father node, and lost its correspondent path. Below is the data of my Firebase DB that illustrates the issue better:
{
"districts" : {
"did01" : {
"name" : "Teusaquillo",
"peopleids" : {
"stateid01" : true,
"stateid02" : true,
"stateid03" : true
},
"schools" : {
"schoolid01" : {
"location" : "norte 50 grados sur 42 ",
"name" : "Agustiniano Salitre",
"posts" : {
"eighth" : {
"nola" : "hola"
},
"eighth-KaG1PA5r7cl70FtBsE4" : "angela",
"eleventh" : {
"name" : "haka"
},
"eleventh-KaG1PA5r7cl70FtBsE4" : "angela",
"fifth" : {
"-KaG1PA5r7cl70FtBsE4" : "angela",
"dsadsad" : {
"name" : "Hola"
},
"dsfsdfdsf" : true
},
"first" : {
"1" : {
"author" : "Giovanny Piñeros",
"text" : "Test"
},
"01" : {
"author" : "Giovanny Piñeros",
"text" : "Capo"
},
"abdffg" : {
"author" : "Gio",
"text" : "hola"
},
"fdgfdg" : {
"author" : "Giovanny Piñeros",
"text" : "Hola"
},
"nfdsfds" : {
"author" : "Giovanny Piñeros",
"text" : "Vivir de lo que amo"
},
"postid01" : {
"author" : "Papa frita",
"text" : "Hola",
"topic" : "Informatics",
"year" : "first"
},
"rtyrty" : {
"author" : "Giovanny Piñeros",
"text" : "Si con headapp solo sabia manejar strings y colores, imaginate ahora lo que puedo crear"
},
"zsadsa" : {
"author" : "Gio",
"text" : "Trest"
}
},
"fourth" : {
"name" : "hqiq"
},
"fourth-KaG1PA5r7cl70FtBsE4" : "angela",
"ninth" : {
"hola" : "ahah"
},
"ninth-KaG1PA5r7cl70FtBsE4" : "angela",
"postid01" : {
"-KaG0b-X9sWXxXlXlmeK" : "angela",
"-KaG0wNu0Gz5oxu4__Ej" : "angela",
"author" : "Papa frita",
"likes" : {
"userid01" : "Giovanny Piñeros"
},
"text" : "hola",
"topic " : "Informatics",
"year" : "first"
},
"postid02" : {
"autor" : "Directive",
"text" : "Free for the day",
"topic" : "General",
"year" : "all"
},
"second" : {
"-KaFnTl89keEOx3UpnGJ" : true,
"-KaFpLsNy6z-TshUJONx" : true,
"-KaFpMwBdHqBwsq-k6i3" : true,
"-KaFpz6qwQ2uTevvpxXo" : true,
"-KaFq21Qdv-Z6KFcu8ZT" : true,
"-KaFq34fN1-ZxO0EtqEw" : true,
"-KaFv7a9JvEjPLDDzT8S" : "angela",
"-KaFw9Hb6OjIRzeP6jdk" : "angela",
"-KaFwAFvFoVEvpzaaVO2" : "angela",
"-KaFwAboyWtEOG3NU1yZ" : "angela",
"-KaFwAji3rR6e5fCHjFc" : "angela",
"-KaFwAmisIA5i4UhvcRw" : "angela",
"-KaFyJHEqDzoVoj_zUWI" : "angela",
"-KaFy_cqf1mvTxRGN5j_" : "angela",
"-KaG-_r4ql2YVc19gbkt" : "angela",
"dsfsdf" : {
"hola" : "dfsad"
}
},
"seventh" : {
"name" : "dsfhksd"
},
"sixth" : {
"name" : "haaka"
},
"tenth" : {
"name" : "hola"
},
"tenth-KaG1PA5r7cl70FtBsE4" : "angela",
"third" : {
"-KaFnTl89keEOx3UpnGJ" : true,
"-KaFpLsNy6z-TshUJONx" : true,
"-KaFpMwBdHqBwsq-k6i3" : true,
"-KaFpz6qwQ2uTevvpxXo" : true,
"-KaFq21Qdv-Z6KFcu8ZT" : true,
"-KaFq34fN1-ZxO0EtqEw" : true,
"-KaFv7a9JvEjPLDDzT8S" : "angela",
"-KaFw9Hb6OjIRzeP6jdk" : "angela",
"-KaFwAFvFoVEvpzaaVO2" : "angela",
"-KaFwAboyWtEOG3NU1yZ" : "angela",
"-KaFwAji3rR6e5fCHjFc" : "angela",
"-KaFwAmisIA5i4UhvcRw" : "angela",
"-KaFyJHEqDzoVoj_zUWI" : "angela",
"-KaFy_cqf1mvTxRGN5j_" : "angela",
"-KaG-_r4ql2YVc19gbkt" : "angela",
"-KaG0b-X9sWXxXlXlmeK" : "angela",
"-KaG0wNu0Gz5oxu4__Ej" : "angela",
"-KaG1PA5r7cl70FtBsE4" : "angela",
"author" : "hola"
},
"twelfth" : {
"name" : "haoao"
}
},
"users" : {
"userid01" : {
"likes" : {
"postid01" : true
},
"name" : "Giovanny Piñeros",
"rol" : "student",
"stateid" : "stateid01",
"year" : "first"
},
"userid03" : {
"Posts" : {
"postid01" : {
"fjsldkfj" : "nombre",
"texzto" : "fksdjh"
}
},
"name" : "Papa frita",
"rol" : "teacher"
}
}
}
}
},
"did02" : {
"name" : "Austin",
"peopleids" : {
"stateid04" : true,
"stateid05" : true,
"stateid06" : true
}
}
},
"eventos" : {
"attendiees" : {
"adshfksafjh" : "giovanny"
},
"nombre" : "fiesta"
},
"queue" : {
"specs" : {
"specstest" : 0
},
"tasks" : {
"ido" : {
"_error_details" : {
"error" : "Task was malformed",
"error_stack" : "Error: Task was malformed\n at Object.update (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-queue/dist/lib/queue_worker.js:453:27)\n at Ih (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:233:395)\n at R.h.transaction (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:248:466)\n at /Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-queue/dist/lib/queue_worker.js:446:30\n at c (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:135:58)\n at /Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:126:791\n at Ac (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:63:165)\n at jf (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:126:215)\n at hf (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:125:479)\n at vf (/Users/Giovanny/Dropbox/Proyectos/NotifyMe/NotifyMeServer/notifymeserver/node_modules/firebase-admin/lib/database/database.js:231:426)",
"original_task" : 0
},
"_state" : "error",
"_state_changed" : 1482958978549
}
}
},
"usuarios" : {
"hvlksdj" : {
"edad" : 26,
"nombre" : "giovanny"
}
}
}
As you can see, the child nodes postid01 and second are updated, creating a new child, but for the other locations, this doesn't happen.
Here is my code. I did the following according to the Firebase guidelines:
let ref = FIRDatabase.database().reference()
var newPost = ref.childByAutoId()
let newKey = newPost.key
let dict = ["districts/did01/schools/schoolid01/posts/fifth/\(newKey)" : "test","districts/did01/schools/schoolid01/posts/third/\(newKey)": "test",
"districts/did01/schools/schoolid01/posts/fourth\(newKey)": "test","districts/did01/schools/schoolid01/posts/postid02\(newKey)": "test",
"districts/did01/schools/schoolid01/posts/sixth\(newKey)": "test","districts/did01/schools/schoolid01/posts/seventh\(newKey)": "test",
"districts/did01/schools/schoolid01/posts/eighth\(newKey)": "test", "districts/did01/schools/schoolid01/posts/ninth\(newKey)": "test", "districts/did01/schools/schoolid01/posts/tenth\(newKey)": "test", "districts/did01/schools/schoolid01/posts/eleventh\(newKey)": "test", "districts/did01/schools/schoolid01/posts/postid04\(newKey)" : "test"]
ref.updateChildValues(dict, withCompletionBlock: {(Error,FIRDatabaseReference) in
if(Error == nil){
print("EXITO :)")
}else{
print("PAILA :(")
}
})
I've just found the error, it was so simple, i make a mistake on the dictionary. The locations that weren't updated were written like this :
"districts/did01/schools/schoolid01/posts/fourth\(newKey)": "test"
As you can see the last part is missing a "/" just before the newKey.
Is it possible to create Salesreceipt without product/service value through QBO API? I have tried through API but it's not reflecting rate value and storing description value only.
If I remove ItemRef attribute(in request body) then it's reflecting rate and amount values and it's assigning some default and random product/service.
It is possible directly in QBO UI.
Request body where only description value storing:
{
"TxnDate" : "2016-05-27",
"Line" : [ {
"Amount" : 2222.00,
"Description" : "hi chk",
"DetailType" : "ItemReceiptLineDetail",
"ItemReceiptLineDetail" : {
"ItemRef" : { },
"Qty" : 1,
"UnitPrice" : 2222
} }
],
"CustomerRef" : {
"value" : "67"
},
"CustomerMemo" : {
"value" : "Thanks for your business! We appreciate referrals!"
},
"TotalAmt": 2222.00,
"PrivateNote" : "",
"CustomField" : [ {
"DefinitionId" : "1",
"Type" : "StringType",
"StringValue" : ""
} ]
}
Request body where default product/service assigning:
{
"TxnDate" : "2016-05-27",
"Line" : [ {
"Amount" : 2222.00,
"Description" : "hi chk",
"DetailType" : "ItemReceiptLineDetail",
"ItemReceiptLineDetail" : {
"Qty" : 1,
"UnitPrice" : 2222
} }
],
"CustomerRef" : {
"value" : "67"
},
"CustomerMemo" : {
"value" : "Thanks for your business! We appreciate referrals!"
},
"TotalAmt": 2222.00,
"PrivateNote" : "",
"CustomField" : [ {
"DefinitionId" : "1",
"Type" : "StringType",
"StringValue" : ""
} ]
}
No.
QuickBooks Online does not support this.
I want to retrieve data from a JSON file with SwiftyJSON and Alamofire. This is the JSON data:
json: {
"data" : {
"monitors" : [
{
"lines" : [
{
"towards" : "LEOPOLDAU",
"realtimeSupported" : true,
"departures" : {
"departure" : [
{
"departureTime" : {
"countdown" : 2,
"timePlanned" : "2015-09-09T18:47:03.000+0200",
"timeReal" : "2015-09-09T18:47:03.000+0200"
}
},
{
"departureTime" : {
"countdown" : 6,
"timePlanned" : "2015-09-09T18:51:03.000+0200",
"timeReal" : "2015-09-09T18:51:03.000+0200"
}
}
]
},
"lineId" : 301,
"platform" : "1",
"trafficjam" : false,
"richtungsId" : "1",
"direction" : "H",
"type" : "ptMetro",
"name" : "U1",
"barrierFree" : true
}
],
"attributes" : {
},
"locationStop" : {
"type" : "Feature",
"geometry" : {
"type" : "Point",
"coordinates" : [
16.4330680046932,
48.2430825589716
]
},
"properties" : {
"municipality" : "Wien",
"title" : "Kagran",
"coordName" : "WGS84",
"municipalityId" : 90000,
"type" : "stop",
"gate" : "1",
"name" : "60200627",
"attributes" : {
"rbl" : 4127
}
}
}
}
]
}
,
"message" : {
"value" : "OK",
"serverTime" : "2015-09-09T18:45:08.998+0200",
"messageCode" : 1
}
}
What I want to do now is get the data of lines into an array. I tried several combinations for that, e.g.
let departureArray = jsonData["data"]["monitors"][0]["lines"][0].array
or
let departureArray = jsonData["data"]["monitors"]["lines"].array
but my array is always empty. Does anyone has an idea how to do this properly?
Your expected array departureArray is in fact a dictionary
let departureDictionary = jsonData["data"]["monitors"][0]["lines"][0].dictionary