Using Basic HTTP-Auth with ESP8266

Globment.de - Blog

Lib to generate JSON String from local storage values
If you want to generate a JSON String from your local storage data this lib has some useful functions. It is not possible to generate a JSON String from already stored values.



        /*
        * lib.js - Generates JSON String from Local Storage Values
        * Version 0.0.1   
        * (c) copyright 2022 globment.de
        * 
        */
       
       var storageArray = new Array();
       var storageIndex = 0;
       
       class StorageClass {
           key = "";
           value = "";
       
           constructor(key, value) {
               this.key = key;
               this.value = value;
           }
       }
       
       function findValue(value) {
           storageArray.forEach(val => {
               console.log(val);
               if(val === value) {
                   return val;
               }    
           });
           return null;
       }
       
       function generateDummyStorage() {
           for(var j = storageIndex; j < storageIndex + 3; j++) {
               setItemToLocalStorage("dummyKey_" + j, "dummyValue");
           }
           storageIndex += 3;
       }
       
       function setItemToLocalStorage(key, value) {
           storageObj = new StorageClass(key, value); 
           localStorage.setItem(key, value);
           storageArray.push(storageObj);
       }
       
       
       function getJson() {
           return JSON.stringify(storageArray);
       }