ESP8266 JSON response

Hello there. My question is can I store json data values from API Response on ESP8266?
Here is how I sent API Request to server:

int httpCode = http.GET();
String payload = http.getString();
getData = "?device_token=" + String(device_token)+"&frissit=1";
Link = URL + getData;
http.begin (wifiClient, Link);
int httpCode1 = http.GET();
String payload1=http.getString();

And from Server Side this is the way how I got the response:

while ( $row = mysqli_fetch_assoc( $resultl ))
{

    $response[]  =  $row["card_uid"];
}
header('Access-Control-Allow-Origin: *');

header('Content-type: application/json');
echo json_encode($response,JSON_PRETTY_PRINT);

[
    "49627186841128",
    "145508136",
    "1614213828",
    "972048638",
    "3291528",
    "220145112192"
]

And How I want to store this values on a json file from where I can get the values... I try it on this way:

 if(httpCode == 200)
  {
    Serial.print(payload1);
    StaticJsonDocument<1024> doc;
    deserializeJson(doc,payload1);
   const char* kartya=doc[15];
   Serial.println(kartya);
   
    }}

But dont work....

Your StaticJsonDocument (doc) only has 6 elements and you are asking for the 16th element?!?

Yes I know i just test it if is giving the same response. But I found what was the problem. Thanks anyway.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.