Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include"FS.h"
  2. #include <ESP8266WiFi.h>
  3. #include <ArduinoJson.h>
  4.  
  5. //String file_name = "/config1.json"; // File of interest
  6.  
  7. void setup() {
  8. WiFi.disconnect();
  9. Serial.begin(115200);
  10. while (!Serial);
  11. bool exist;
  12. bool ok = SPIFFS.begin();
  13.  
  14.  
  15.  
  16. // Open file
  17. File file = SPIFFS.open("/config1.json","r");
  18.  
  19.  
  20. while(file.available())
  21.  
  22. {
  23.  
  24. StaticJsonBuffer<1024> jb;
  25.  
  26. JsonArray& arr = jb.parseArray(file);
  27.  
  28.  
  29. for(int i=0;i<arr.size();i++)
  30. {
  31.  
  32.  
  33. JsonObject& forecast = arr[i]["forecast"];
  34.  
  35.  
  36.  
  37. Serial.println(forecast["date"].as<char*>());
  38. Serial.println(forecast["text"].as<char*>());
  39. Serial.println(forecast["high"].as<int>());
  40. Serial.println(forecast["low"].as<int>());
  41.  
  42.  
  43. }
  44. }
  45. }
  46. void loop() {
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement