From 6757a017aa184541a997c83f252482177479f521 Mon Sep 17 00:00:00 2001 From: acasadoalonso Date: Mon, 27 Jul 2015 16:28:07 +0200 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Examples.md b/Examples.md index 78589c8..23b614c 100644 --- a/Examples.md +++ b/Examples.md @@ -1,3 +1,34 @@ +## Example 2: get the weather data from aviationweather.gov or geonames.org + char *MTserverName = "api.geonames.org"; // server name + String cmd = "GET /weatherIcaoJSON?ICAO="; // prepare the command to send to the web server after + +getting the data on JSON format and parsing the buffer: + + + JsonObject& _root = jsonBuffer.parseObject(MTjson); // parse the JSON buffer + + if (!_root.success()) { // everything OK + Serial.println("MTparseObject() failed"); + delay(10000); + __wferrno=-2; // set the error code + return NULL; + } + if (Debug&&Debugplus) Serial.println("Beauty print..."); + if (Debug&&Debugplus) _root.prettyPrintTo(Serial); // print it on prettyPrint format + if (Debug&&Debugplus) Serial.println("END of Beauty print..."); + + JsonObject & _ooo = _root["weatherObservation"]; // query root + MET->MTobservation = _ooo ["observation"]; // raw observation + MET->MTtemp = _ooo ["temperature"]; // temp + MET->MTpressure = _ooo ["hectoPascAltimeter"]; // QNH + MET->MTQNH = _ooo ["hectoPascAltimeter"]; // QNH + MET->MTdewpoint = _ooo ["dewPoint"]; // Dew point + MET->MThumidity = _ooo ["humidity"]; // humidity % + MET->MTwinddeg = _ooo ["windDirection"]; // wind + MET->MTwindspeed = _ooo ["windSpeed"]; // speed + MET->MTobservationtime= _ooo ["datetime"]; // time + + ## Example 1: complex nested object From [issue #85](https://github.com/bblanchon/ArduinoJson/issues/85): @@ -23,4 +54,3 @@ Can be generated by the following code: root.prettyPrintTo(Serial); Don't forget to replace the `DynamicJsonBuffer` by a `StaticJsonBuffer` if you need to run on an embedded platform like an Arduino. -