Closed mrohner closed 7 years ago
Hi I'm currently working on a blog post which will be published this Friday about how to use the parser. You can see the draft in the attachment. Let me know if that helped or what is unclear... [ESP8266 The JSON Streaming Parser Squix - TechBlog.pdf](https://github.com/squix78/json-streaming-parser/files/723785/ESP8266.The.JSON.Streaming.Parser..Squix.-.TechBlog.pdf)
Hallo Daniel,
Danke für das Dokument. Woher nimmst Du die City, scheint ja gar nicht in Deinem JSON stream vorhanden zu sein.
Nein, leider verstehe ich's immer noch nicht. Wie kann man Objekte überspringen? In meinem Datenstrom kommen die selben Keys immer wieder vor (brauche sie aber nicht). Ich hab die für mich relevanten Felder rot markiert.
Ich verstehe, dass ich ein eigenes .CPP erstellen soll.
Jetzt will nach dem key "name" suchen, aber nicht das gelb markierte, sondern das rote. Wie spring ich jetzt an diese Position?
Dann brauch ich zwei Mal den key "countdown" und dann lange nichts mehr bis zum nächsten "product".
Wie springe ich zum nächsten Objekt? Kann ich dann jezt endObject(); aufrufen oder endArray(); oä.?
Danke für Deine Hilfe
{ "station":{ "name":"Zürich Oerlikon (SBB)", "additionalInformation":{ "attr_MU": false, "attr_HU": true, "attr_HU_val": "13034" ,"timetableUrl":"http://www.zvv.ch/zvv/de/fahrplan/haltestellenfahrplaene.html?hstNr=13034" } }, "connections":[ { "name":"0", "date":"23.01.17", "product":{ "name":"Trm 14", "longName":"Tram", "type":"9" ,"line":"14" ,"direction":"Zürich, Triemli" ,"directionType":"to" ,"icon":"icon_tram" ,"color":{"fg":"ffffff","bg":"008dc5"} } , "mainLocation":{ "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:14", "countdown":"58", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } }, "locations":[ { "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:14", "countdown":"58", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Sternen Oerlikon", "x":8546225, "y":47410062, "id":"299706", "tupelId":"", "type":"STATION" }, "time":"16:16", "countdown":"60", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Salersteig", "x":8548481, "y":47406071, "id":"299429", "tupelId":"", "type":"STATION" }, "time":"16:17", "countdown":"61", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Berninaplatz", "x":8548094, "y":47403671, "id":"299718", "tupelId":"", "type":"STATION" }, "time":"16:18", "countdown":"62", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Milchbuck", "x":8541757, "y":47397783, "id":"299807", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofquai/HB", "x":8541685, "y":47377476, "id":"299983", "tupelId":"", "type":"STATION" }, "time":"16:31", "countdown":"75", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofplatz/HB", "x":8539294, "y":47377242, "id":"299985", "tupelId":"", "type":"STATION" }, "time":"16:33", "countdown":"77", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Stauffacher", "x":8529244, "y":47373413, "id":"299709", "tupelId":"", "type":"STATION" }, "time":"16:38", "countdown":"82", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Schmiede Wiedikon", "x":8519068, "y":47370123, "id":"299743", "tupelId":"", "type":"STATION" }, "time":"16:45", "countdown":"89", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Triemli", "x":8495346, "y":47368046, "id":"299689", "tupelId":"", "type":"STATION" }, "time":"16:51", "countdown":"95", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"985344/331620/833882/88493/85", "cancelled":false, "attributes_bfr":[ { "code":"NF", "text":"Niederflurfahrzeug", "priority":"100", "hightPriority":false } ], "attributes":[ { "code":"NF", "text":"Niederflurfahrzeug", "priority":"100", "hightPriority":false } ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } , { "name":"1", "date":"23.01.17", "product":{ "name":"S 9", "longName":"S-Bahn", "type":"5" ,"line":"S 9" ,"direction":"Uster" ,"directionType":"to" ,"icon":"icon_train" ,"color":{"fg":"000000","bg":"FFFFFF"} } , "mainLocation":{ "location":{ "name":"Zürich Oerlikon (SBB)", "x":8544400, "y":47411896, "id":"8503006", "tupelId":"", "type":"STATION" }, "time":"16:15", "countdown":"59", "date":"23.01.17", "platform":"7", "realTime": { "time":"16:15", "countdown":"59", "date":"23.01.17", "delay":"0", "platform":"7", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } }, "locations":[ { "location":{ "name":"Zürich Oerlikon (SBB)", "x":8544400, "y":47411896, "id":"8503006", "tupelId":"", "type":"STATION" }, "time":"16:15", "countdown":"59", "date":"23.01.17", "platform":"7", "realTime": { "time":"16:15", "countdown":"59", "date":"23.01.17", "delay":"0", "platform":"7", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } } , { "location":{ "name":"Zürich Hardbrücke (SBB)", "x":8516902, "y":47385440, "id":"8503020", "tupelId":"", "type":"STATION" }, "time":"16:19", "countdown":"63", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich HB", "x":8537945, "y":47378492, "id":"8503000", "tupelId":"", "type":"STATION" }, "time":"16:23", "countdown":"67", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich Stadelhofen (SBB)", "x":8548661, "y":47366707, "id":"8503003", "tupelId":"", "type":"STATION" }, "time":"16:30", "countdown":"74", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Stettbach", "x":8596133, "y":47397279, "id":"8503147", "tupelId":"", "type":"STATION" }, "time":"16:35", "countdown":"79", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Dübendorf", "x":8622912, "y":47400488, "id":"8503128", "tupelId":"", "type":"STATION" }, "time":"16:38", "countdown":"82", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Schwerzenbach ZH", "x":8658760, "y":47384173, "id":"8503127", "tupelId":"", "type":"STATION" }, "time":"16:41", "countdown":"85", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Nänikon-Greifensee", "x":8685980, "y":47369476, "id":"8503126", "tupelId":"", "type":"STATION" }, "time":"16:44", "countdown":"88", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Uster", "x":8718179, "y":47350832, "id":"8503125", "tupelId":"", "type":"STATION" }, "time":"16:49", "countdown":"93", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"955512/334550/634192/1408/85", "cancelled":false, "attributes_bfr":[ ], "attributes":[ ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } , { "name":"2", "date":"23.01.17", "product":{ "name":"Trm 10", "longName":"Tram", "type":"9" ,"line":"10" ,"direction":"Zürich, Bahnhofplatz/HB" ,"directionType":"to" ,"icon":"icon_tram" ,"color":{"fg":"ffffff","bg":"e12472"} } , "mainLocation":{ "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:19", "countdown":"63", "date":"23.01.17", "platform":"", "realTime": { "time":"16:19", "countdown":"63", "date":"23.01.17", "delay":"0", "platform":"", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } }, "locations":[ { "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:19", "countdown":"63", "date":"23.01.17", "platform":"", "realTime": { "time":"16:19", "countdown":"63", "date":"23.01.17", "delay":"0", "platform":"", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } } , { "location":{ "name":"Zürich, Sternen Oerlikon", "x":8546225, "y":47410062, "id":"299706", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Salersteig", "x":8548481, "y":47406071, "id":"299429", "tupelId":"", "type":"STATION" }, "time":"16:23", "countdown":"67", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Berninaplatz", "x":8548094, "y":47403671, "id":"299718", "tupelId":"", "type":"STATION" }, "time":"16:24", "countdown":"68", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Milchbuck", "x":8541757, "y":47397783, "id":"299807", "tupelId":"", "type":"STATION" }, "time":"16:26", "countdown":"70", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Langmauerstrasse", "x":8544786, "y":47393531, "id":"8591244", "tupelId":"", "type":"STATION" }, "time":"16:30", "countdown":"74", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Letzistrasse", "x":8545496, "y":47390681, "id":"299834", "tupelId":"", "type":"STATION" }, "time":"16:31", "countdown":"75", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Seilbahn Rigiblick", "x":8548301, "y":47386043, "id":"299489", "tupelId":"", "type":"STATION" }, "time":"16:33", "countdown":"77", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Central", "x":8543959, "y":47376802, "id":"299959", "tupelId":"", "type":"STATION" }, "time":"16:41", "countdown":"85", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofplatz/HB", "x":8539294, "y":47377242, "id":"299985", "tupelId":"", "type":"STATION" }, "time":"16:43", "countdown":"87", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"337653/114714/608910/191904/85", "cancelled":false, "attributes_bfr":[ { "code":"NF", "text":"Niederflurfahrzeug", "priority":"100", "hightPriority":false } ], "attributes":[ { "code":"NF", "text":"Niederflurfahrzeug", "priority":"100", "hightPriority":false } ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } , { "name":"3", "date":"23.01.17", "product":{ "name":"Trm 11", "longName":"Tram", "type":"9" ,"line":"11" ,"direction":"Zürich, Rehalp" ,"directionType":"to" ,"icon":"icon_tram" ,"color":{"fg":"ffffff","bg":"00892f"} } , "mainLocation":{ "location":{ "name":"Zürich, Bahnhof Oerlikon", "x":8544867, "y":47411464, "id":"299620", "tupelId":"", "type":"STATION" }, "time":"16:20", "countdown":"64", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } }, "locations":[ { "location":{ "name":"Zürich, Bahnhof Oerlikon", "x":8544867, "y":47411464, "id":"299620", "tupelId":"", "type":"STATION" }, "time":"16:20", "countdown":"64", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Regensbergbrücke", "x":8539276, "y":47408812, "id":"299774", "tupelId":"", "type":"STATION" }, "time":"16:22", "countdown":"66", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bad Allenmoos", "x":8537784, "y":47405891, "id":"299783", "tupelId":"", "type":"STATION" }, "time":"16:23", "countdown":"67", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Radiostudio", "x":8535186, "y":47401972, "id":"299459", "tupelId":"", "type":"STATION" }, "time":"16:24", "countdown":"68", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofquai/HB", "x":8541685, "y":47377476, "id":"299983", "tupelId":"", "type":"STATION" }, "time":"16:36", "countdown":"80", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofstrasse/HB", "x":8539447, "y":47376209, "id":"299570", "tupelId":"", "type":"STATION" }, "time":"16:38", "countdown":"82", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Paradeplatz", "x":8538907, "y":47369727, "id":"299785", "tupelId":"", "type":"STATION" }, "time":"16:42", "countdown":"86", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bürkliplatz", "x":8540768, "y":47366527, "id":"299964", "tupelId":"", "type":"STATION" }, "time":"16:45", "countdown":"89", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bellevue", "x":8545083, "y":47367076, "id":"299979", "tupelId":"", "type":"STATION" }, "time":"16:46", "countdown":"90", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Rehalp", "x":8582981, "y":47351021, "id":"299713", "tupelId":"", "type":"STATION" }, "time":"16:59", "countdown":"103", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"843105/283443/755356/96643/85", "cancelled":false, "attributes_bfr":[ ], "attributes":[ ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } , { "name":"4", "date":"23.01.17", "product":{ "name":"S 6", "longName":"S-Bahn", "type":"5" ,"line":"S 6" ,"direction":"Uetikon am See" ,"directionType":"to" ,"icon":"icon_train" ,"color":{"fg":"000000","bg":"FFFFFF"} } , "mainLocation":{ "location":{ "name":"Zürich Oerlikon (SBB)", "x":8544400, "y":47411896, "id":"8503006", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"7", "realTime": { "time":"16:21", "countdown":"65", "date":"23.01.17", "delay":"0", "platform":"7", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } }, "locations":[ { "location":{ "name":"Zürich Oerlikon (SBB)", "x":8544400, "y":47411896, "id":"8503006", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"7", "realTime": { "time":"16:21", "countdown":"65", "date":"23.01.17", "delay":"0", "platform":"7", "isPlatformChanged":false, "isDelayed":false, "hasRealTime":true } } , { "location":{ "name":"Zürich Hardbrücke (SBB)", "x":8516902, "y":47385440, "id":"8503020", "tupelId":"", "type":"STATION" }, "time":"16:24", "countdown":"68", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich HB", "x":8537945, "y":47378492, "id":"8503000", "tupelId":"", "type":"STATION" }, "time":"16:28", "countdown":"72", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich Stadelhofen (SBB)", "x":8548661, "y":47366707, "id":"8503003", "tupelId":"", "type":"STATION" }, "time":"16:32", "countdown":"76", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich Tiefenbrunnen (SBB)", "x":8561650, "y":47350194, "id":"8503004", "tupelId":"", "type":"STATION" }, "time":"16:35", "countdown":"79", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Küsnacht ZH", "x":8580869, "y":47319226, "id":"8503101", "tupelId":"", "type":"STATION" }, "time":"16:42", "countdown":"86", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Erlenbach ZH", "x":8591575, "y":47305994, "id":"8503102", "tupelId":"", "type":"STATION" }, "time":"16:45", "countdown":"89", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Winkel am Zürichsee", "x":8598973, "y":47297202, "id":"8503111", "tupelId":"", "type":"STATION" }, "time":"16:46", "countdown":"90", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Meilen", "x":8644315, "y":47269776, "id":"8503104", "tupelId":"", "type":"STATION" }, "time":"16:53", "countdown":"97", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Uetikon am See", "x":8678770, "y":47258971, "id":"8503105", "tupelId":"", "type":"STATION" }, "time":"16:57", "countdown":"101", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"153465/67080/628816/263253/85", "cancelled":false, "attributes_bfr":[ ], "attributes":[ ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } , { "name":"5", "date":"23.01.17", "product":{ "name":"Trm 14", "longName":"Tram", "type":"9" ,"line":"14" ,"direction":"Zürich, Triemli" ,"directionType":"to" ,"icon":"icon_tram" ,"color":{"fg":"ffffff","bg":"008dc5"} } , "mainLocation":{ "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } }, "locations":[ { "location":{ "name":"Zürich, Bahnhof Oerlikon Ost", "x":8545847, "y":47413334, "id":"299598", "tupelId":"", "type":"STATION" }, "time":"16:21", "countdown":"65", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Sternen Oerlikon", "x":8546225, "y":47410062, "id":"299706", "tupelId":"", "type":"STATION" }, "time":"16:23", "countdown":"67", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Salersteig", "x":8548481, "y":47406071, "id":"299429", "tupelId":"", "type":"STATION" }, "time":"16:25", "countdown":"69", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Berninaplatz", "x":8548094, "y":47403671, "id":"299718", "tupelId":"", "type":"STATION" }, "time":"16:26", "countdown":"70", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Milchbuck", "x":8541757, "y":47397783, "id":"299807", "tupelId":"", "type":"STATION" }, "time":"16:28", "countdown":"72", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofquai/HB", "x":8541685, "y":47377476, "id":"299983", "tupelId":"", "type":"STATION" }, "time":"16:38", "countdown":"82", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Bahnhofplatz/HB", "x":8539294, "y":47377242, "id":"299985", "tupelId":"", "type":"STATION" }, "time":"16:41", "countdown":"85", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Stauffacher", "x":8529244, "y":47373413, "id":"299709", "tupelId":"", "type":"STATION" }, "time":"16:46", "countdown":"90", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Schmiede Wiedikon", "x":8519068, "y":47370123, "id":"299743", "tupelId":"", "type":"STATION" }, "time":"16:52", "countdown":"96", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } , { "location":{ "name":"Zürich, Triemli", "x":8495346, "y":47368046, "id":"299689", "tupelId":"", "type":"STATION" }, "time":"16:58", "countdown":"102", "date":"23.01.17", "platform":"", "realTime": { "time":"", "countdown":"", "date":"", "delay":"", "platform":"", "isPlatformChanged":false, "isDelayed":true, "hasRealTime":false } } ], "trainInfo":"601617/203712/923736/261330/85", "cancelled":false, "attributes_bfr":[ ], "attributes":[ ], "himMessages":[ ], "hasHIMMessage":false, "hasGlobalHIMMessage":false } ] }
From: Daniel Eichhorn notifications@github.com Sent: Monday, January 23, 2017 2:52 PM To: squix78/json-streaming-parser Cc: mrohner; Author Subject: Re: [squix78/json-streaming-parser] Problem in understanding the example (#8)
Hi I'm currently working on a blog post which will be published this Friday about how to use the parser. You can see the draft in the attachment. Let me know if that helped or what is unclear... ESP8266 The JSON Streaming Parser Squix - TechBlog.pdfhttps://github.com/squix78/json-streaming-parser/files/723785/ESP8266_.The.JSON.Streaming.Parser._.Squix.-.TechBlog.pdf
- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/squix78/json-streaming-parser/issues/8#issuecomment-274492964, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APOd1cBwPOehzxCX7XZwLnTsPcYApVZBks5rVLCrgaJpZM4LqWx9.
I will answer in English, then more people can profit: if your keys are repeating you'll have to remember your context. You could for instance remember the name of the parent of your current object. You do this in the startObject method and remove it in the endObject method. Have a look here: https://github.com/squix78/esp8266-weather-station/blob/master/WundergroundClient.cpp#L195 https://github.com/squix78/esp8266-weather-station/blob/master/WundergroundClient.cpp#L494
The second countdown key/value pair for instance has the parent "realtime". So if you were interested in realtime.countdown value you would check if(currentParent == "realtime" && currentKey == "countdown")
If that doesn't help tell me which attributes you need and I will try to hack together the class for you...
Hi, I gave it a try and even though I still do not fully understand the logic I achieved some promising results. Nevertheless some questions came up (above JSON data is parsed) I get values for "type" and "line" but NOT for the two countdown fields. Any ideas? Is it ok to 'for' loop to capture ten incidents? Is the parent key retained (e.g. "mainLocation") when a subsequent parent (e.g. "location") overwrites the CurrentParent value? The countdown field is still in "mainLocation" but currentParent has already changed to "location"? Thank you
void ZVVClient::value(String value) { for (int i = 0; i < 9 ; i++) { //Number_Journeys if (currentParent == "product") { if (currentKey == "type") { type[i] = value.toInt(); } if (currentKey == "line") { line[i] = value.toInt(); } } if (currentKey == "countdown") { a_countdown[i] = value.toInt(); } if (currentParent == "realTime" && currentKey == "countdown") { countdown[i] = value.toInt(); } } }
I found a solution myself by tracking all the hierarchy levels of the object. Thanks void ZVVClient::value(String value) { //Serial.print(currentParent[hierarchy_level]); //Serial.print(" "); //Serial.println(currentKey); if (currentParent[hierarchy_level] == "product") { // Has a Parent key and 2 sub-keys if (currentKey == "type") { count++; Serial.println(count); type[count] = value.toInt(); //Serial.println(type[count]); } if (currentKey == "line") { line[count] = value.toInt(); //Serial.println(line[count]); } } if (currentParent[hierarchy_level] == "mainLocation" && currentKey == "countdown") { a_countdown[count] = value.toInt(); //Serial.println(a_countdown[count]); } if (currentParent[hierarchy_level-1] == "mainLocation" && currentParent[hierarchy_level] == "realTime" && currentKey == "countdown") { countdown[count] = value.toInt(); //Serial.println(countdown[count]); } }
void ZVVClient::endArray() { }
void ZVVClient::startObject() { hierarchy_level++; currentParent[hierarchy_level] = currentKey; }
void ZVVClient::endObject() { hierarchy_level--; }
This is not about an issue per se but lack of my understanding the example. May be you can give me a hint on how to proceed. This is the link to the json I'm trying to parse: http://online.fahrplan.zvv.ch/bin/stboard.exe/dny?input=Z%C3%BCrich,+Oerlikon+(SBB)&dirInput=Z%C3%BCrich+HB&maxJourneys=6&boardType=dep&start=1&tpl=stbResult2json
How do I translate this to the structure given in the example: char json[] = "{"a":3, "b":{"c":"d"}}";
Any idea?