Problems with arduniojson code. expected unqualified-I’d before this #HELP PLEASE#

only posting one of my voids if that helps

void readings(){

Serial.println("");
Serial.println("-----");
Serial.print("data run #");

client.setTimeout(10000);
if (!client.connect(host,80)){
Serial.println(("connection failed"));
return;
}

client.println(F("GET get/latest/dweet/for/thomastech HTTP/1.0"));
client.println(F("Host:dweet.io"));
client.println(F("connection closed"));
if (client.println()==0){
Serial.println(F("failed to send request"));
return;
}
char endOfHeaders[] = "\r\n\r\n";
if (!client.find(endOfHeaders)){
Serial.println(F("invaild response"));
return;
}
StaticJsonDocument<384> doc;

DeserializationError error = deserializeJson(doc, client);

if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}

const char* this = doc["this"]; // "succeeded"
const char* by = doc["by"]; // "getting"
const char* the = doc["the"]; // "dweets"

JsonObject with_0 = doc["with"][0];
const char* with_0_thing = with_0["thing"]; // "thomastech"
const char* with_0_created = with_0["created"]; // "2022-11-16T17:03:57.721Z"
int ledstatus = with_0["content"]["led status"];
Serial.print("ledstatus");
Serial.println(ledstatus);

client.stop();
}

void loop (){}

keeps coming up with error : Compilation error: expected unqualified-id before 'this'

this is a reserved keyword. Please rename your variable.

Thank you can I name it to anything

without seeing all the code difficult tp determine error
could be a problem in using this

const char* this = doc["this"]; // "succeeded"

C++ has a pointer called this
change the name of the identifier?

Anything that is not a reserved keyword (e.g., not if, for, etc.). Probably docThis would be a safe bet.

Yeah I think so it keeps telling me I need something needs to be before this but not sure what

(post deleted by author)

Hi,
first read " How to get the best out of this forum"
Then edit your post and put your code between the </> tags.

Tell us everything about your project, so we can understand it and help you better.

For example:
What release of your IDE?
Which arduinJson.h library release are you using?
Etc. etc......

And other information can help us.

@tom141,

Your two topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

oh sorry this is my first time using this


#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>




const char* ssid ="BT-QQA2W6";
const char* password ="";


int red = 4;
int yellow = 2;
int green = 3; 

float redlimit = 1;
float yellowlimit=2;
float greenlimit = 3;



char host[] = "dweet.io";

WiFiClient client;

//Dweet dweet(client);

void connectToWiFi(){

 Serial.begin(115200);
 Serial.println();
  Serial.println();
  Serial.print("connect to wifi");
  Serial.print("...");

  WiFi.begin(ssid, password);
  int retries = 0;
  while((WiFi.status() !=WL_CONNECTED)&& (retries <15)){
    retries ++;
    delay(500);
    Serial.print(".");
  }

if (retries>14){
Serial.println(F("WiFi connection failed "));
}
if (WiFi.status()==WL_CONNECTED){
  Serial.println(F("wifi conneted"));
Serial.println("IP adress");
Serial.println(WiFi.localIP());
}
Serial.println(F("setup"));
}

void setup(){
 Serial.begin(115200);

  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(yellow, OUTPUT);
  connectToWiFi();
  readings();
 
}




void readings(){

 Serial.println("");
 Serial.println("-----");
 Serial.println("data run #");


 client.setTimeout(10000);
 if (!client.connect(host,80)){
 Serial.println(("connection failed"));
 return;
 }

 client.println(F("GET /get/latest/dweet/for/thomastech HTTP/1.0"));
 client.println(F("Host:dweet.io"));
 client.println(F("connection closed"));
 if (client.println()==0){
 Serial.println(F("failed to send request"));
 return;
 }
 char endOfHeaders[] = "\r\n\r\n";
 if (!client.find(endOfHeaders)){
  Serial.println(F("invaild response"));
  return;
 }
 StaticJsonDocument<384> doc;

DeserializationError error = deserializeJson(doc, client);

if (error) {
  Serial.print(F("deserializeJson() failed: "));
  Serial.println(error.f_str());
  return;
}

JsonObject with_0 = doc["with"][0];
const char* with_0_thing = with_0["thing"]; // "thomastech"
const char* with_0_created = with_0["created"]; // "2022-11-16T17:03:57.721Z"
int ledstatus = with_0["content"]["led status"];
Serial.print("ledstatus:");
Serial.println(ledstatus);

client.stop();
}


void loop (){}

i have fixed the previous code mentioned but now no matter the input i give the webiste the led status on the serial monitor always gives me 0