<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Co je za hodnotu v tom
      myObject["pm2.5_aqi"]?</div>
    <div class="moz-cite-prefix">Je to primo int 36 nebo je to retezec
      "36"?<br>
      Coz bych hledal v dokumentaci toho JSON.parse, jaka je pametova
      reprezentace.</div>
    <div class="moz-cite-prefix">j.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 14.09.2022 15:56, Jan Půhoný wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEwSxSETOKYrddYFAbp9Q4dzhC9WdCG_GNA5BMr_wEOyjiGb7g@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Dobré odpoledne,
        <div><br>
        </div>
        <div>hraju si tady s ESP32 a snažím se vyčíst data z jednoho
          senzoru (z toho PM2,5, o kterém jsme tady před časem mluvili).
          Do teď jsem to dělal přes jejich cloudové API, ale teď to chci
          mít napřímo na IP adresu senzoru ve vnitřní síti.</div>
        <div><br>
        </div>
        <div>Vrací mi to takovýto json:</div>
        <div><br>
        </div>
        <div>{"SensorId":"XXXXXX","DateTime":"2022/09/14T13:22:13z","Geo":"PurpleAir-4ab3","Mem":19696,"memfrag":19,"memfb":15984,"memcs":824,"Id":6086,"lat":50.010101,"lon":16.244499,"Adc":0.00,"loggingrate":15,"place":"inside","version":"7.00","uptime":369517,"rssi":-62,"period":120,"httpsuccess":15372,"httpsends":15493,"hardwareversion":"2.0","hardwarediscovered":"2.0+BME280+PMSX003-A","current_temp_f":86,"current_humidity":37,"current_dewpoint_f":57,"pressure":964.20,"p25aqic":"rgb(95,238,0)","<b>pm2.5_aqi</b>":36,"pm1_0_cf_1":6.17,"p_0_3_um":1070.64,"pm2_5_cf_1":8.59,"p_0_5_um":344.21,"pm10_0_cf_1":10.20,"p_1_0_um":58.06,"pm1_0_atm":6.17,"p_2_5_um":4.54,"pm2_5_atm":8.59,"p_5_0_um":1.99,"pm10_0_atm":10.20,"p_10_0_um":1.19,"pa_latency":474,"response":201,"response_date":1663161645,"latency":1789,"key1_response":200,"key1_response_date":1663161640,"key1_count":132515,"ts_latency":648,"key2_response":200,"key2_response_date":1663161642,"key2_count":132546,"ts_s_latency":616,"key1_response_b":200,"key1_response_date_b":1663161643,"key1_count_b":132566,"ts_latency_b":603,"wlstate":"Connected","status_0":2,"status_1":2,"status_2":2,"status_3":2,"status_4":2,"status_5":2,"status_6":2,"status_7":0,"status_8":2,"status_9":0,"ssid":"puhy_iot"}<br>
        </div>
        <div><br>
        </div>
        <div>a já se snažím z toho dostat jednotlivé hodnoty. Zkoušel
          jsem něco jako:</div>
        <div><br>
        </div>
        <div>http.begin("<a href="http://IP_ADRESA_SENZORU/json"
            moz-do-not-send="true">http://IP_ADRESA_SENZORU/json</a>);
          // HTTP<br>
                  int httpCode = http.GET();<br>
                  // httpCode will be negative on error<br>
                  if (httpCode > 0) {<br>
                      // file found at server<br>
                      if (httpCode == HTTP_CODE_OK) {<br>
                          String response = http.getString();<br>
                          JSONVar myObject = JSON.parse(response);<br>
                          int PM2_5 = atoi(myObject["<b>pm2.5_aqi</b>"]);<br>
                          response = "";<br>
                          http.end();<br>
                          return PM2_5;<br>
                      }<br>
                  } else {<br>
                      http.end();<br>
                      return httpCode;<br>
                  }<br>
        </div>
        <div><br>
        </div>
        <div>Problém je na tomto řádku:</div>
        <div><br>
        </div>
        <div>int PM2_5 = atoi(myObject["<b>pm2.5_aqi</b>"]);<br>
        </div>
        <div><br>
        </div>
        <div>jak z toho dostanu hodnotu int pm2.5_aqi ?</div>
        <div><br>
        </div>
        <div>Díky,</div>
        <div><br>
        </div>
        <div>Honza Půhoný</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
HW-list mailing list  -  sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
    </blockquote>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Jindroush <a class="moz-txt-link-rfc2396E" href="mailto:jindroush@seznam.cz"><jindroush@seznam.cz></a></pre>
  </body>
</html>