Advertisement
DrRandom

theory

Jun 22nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. static const inline void Get_JSON(){
  2.     const size_t capacity = 15000;
  3.     File JSONFILE = SPIFFS.open("/UserProg.json", "r");
  4.     if(!JSONFILE){
  5.         Error_iras("Can't open UserProg.json for read.");
  6.     }else{
  7.         do{
  8.             DynamicJsonDocument doc(capacity);
  9.             DeserializationError error = deserializeJson(doc, JSONFILE);
  10.             if (error) {
  11.                 String Error = String(error.c_str());
  12.                 Error_iras(Error);
  13.             }else {
  14.                 JsonArray content = doc["content"];
  15.                 JsonArray content_0_content = content[0]["content"];
  16.                 for(int x = 0; x < 16;x++){
  17.                     JsonObject content_0_content_0_attributes = content_0_content[x]["attributes"];
  18.                     const char* Addr    = content_0_content_0_attributes["outexp"];
  19.                     const char* pinke   = content_0_content_0_attributes["outpin"];
  20.                     if(pinke[0] != 0){
  21.                         int AddressIndex = String(Addr).indexOf(":");
  22.                         int Address = (String(Addr).substring(AddressIndex+1)).toInt();
  23.                         int PIN     = (String(pinke).substring(7)).toInt();
  24.                         Timers[PIN].Address = Address;
  25.                     }
  26.                 }
  27.             }
  28.         }while(JSONFILE.read() == '?');
  29.     }
  30.     JSONFILE.close();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement