user38031: I have this code:
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "xxxx";
const char* password = "xxxx";

bool a = false;
bool b = true;
int heldVal = 0;

WiFiServer server(80);

void setup () {

  Serial.begin(115200);
  delay(10);

  pinMode(2, INPUT);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

    // Check if a client has connected
    WiFiClient client = server.available();
    if (!client) {

      HTTPClient http;  //Declare an object of class HTTPClient

      int readVal;
      if (!a) {
        if(b) {
          readVal = digitalRead(2);
        }
      }
      else {
        a = false;
        readVal = heldVal;
      }

      if (readVal == 0)
        http.begin("http://192.168.1.100/gpio/0");  //Specify request destination
      else
        http.begin("http://192.168.1.100/gpio/1");

      int httpCode = http.GET();                                                                  //Send the request

      if (httpCode > 0) { //Check the returning code

        String payload = http.getString();   //Get the request response payload
        Serial.println(payload);                     //Print the response payload

      }

      http.end();   //Close connection
      return;
    }

    // Wait until the client sends some data
    Serial.println("new client");
    while (!client.available()) {
      delay(1);
    }

    // Read the first line of the request
    String req = client.readStringUntil('\r');
    Serial.println(req);

    // Match the request
    bool toWrite = true;
    if (req.indexOf("/gpio/0") != -1) {
      heldVal = 0;
      b = false;
    }
    else if (req.indexOf("/gpio/1") != -1) {
      heldVal = 1;
      b = true;
    }
    else if (req.indexOf("/mode") != -1) {
      toWrite = false;

      client.flush();

      Serial.println(String(heldVal));
      Serial.println("---in mode request---");

      String input = "{\"mode\":"+String(heldVal)+"}";
      DynamicJsonBuffer jsonBuffer; //----- PROBLEM LINE -----//
      JsonObject& root = jsonBuffer.parseObject(input);

      // Generate the JSON string
      root.printTo(Serial);

      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: application/json");
      client.println("Connection: close");
      client.println();
      root.printTo(client);
      delay(1);
    }
    else {
      Serial.println("invalid request");
      client.stop();
      return;
    }

    // Set GPIO2 according to the request
    if(toWrite) {
      a = true;

      client.flush();

      // Prepare the response
      String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
      s += (heldVal) ? "high" : "low";
      s += "</html>\n";

      // Send the response to the client
      client.print(s);
      delay(1);
      Serial.println("Client disonnected");

      // The client will actually be disconnected
      // when the function returns and 'client' object is detroyed
    }
  }
  else {
    ESP.restart();
  }

  delay(30000);    //Send a request every 30 seconds

}

I put a comment, //----- PROBLEM LINE -----//, next to the problem line  above. The error is:
/Users/eamonwhite/Documents/Arduino/tempcontrolesp/tempcontrolesp.ino: In function 'void loop()':
tempcontrolesp:110: error: 'DynamicJsonBuffer' was not declared in this scope
       DynamicJsonBuffer jsonBuffer;
       ^
tempcontrolesp:110: error: expected ';' before 'jsonBuffer'
       DynamicJsonBuffer jsonBuffer;
                         ^
tempcontrolesp:111: error: 'JsonObject' was not declared in this scope
       JsonObject& root = jsonBuffer.parseObject(input);
       ^
tempcontrolesp:111: error: 'root' was not declared in this scope
       JsonObject& root = jsonBuffer.parseObject(input);
                   ^
tempcontrolesp:111: error: 'jsonBuffer' was not declared in this scope
       JsonObject& root = jsonBuffer.parseObject(input);
                          ^
exit status 1
'DynamicJsonBuffer' was not declared in this scope

I put it just inside the loop function and it is still giving the same error:
void loop() {
  DynamicJsonBuffer jsonBuffer; //still throws error

How is it not being used correctly? Its just a declaration...

user27653: Did you forget to include the ArduinoJSON header file:
#include <ArduinoJson.h>


38031: <p>I have this code:</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266HTTPClient.h&gt;

const char* ssid = "xxxx";
const char* password = "xxxx";

bool a = false;
bool b = true;
int heldVal = 0;

WiFiServer server(80);

void setup () {

  Serial.begin(115200);
  delay(10);

  pinMode(2, INPUT);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

    // Check if a client has connected
    WiFiClient client = server.available();
    if (!client) {

      HTTPClient http;  //Declare an object of class HTTPClient

      int readVal;
      if (!a) {
        if(b) {
          readVal = digitalRead(2);
        }
      }
      else {
        a = false;
        readVal = heldVal;
      }

      if (readVal == 0)
        http.begin("http://192.168.1.100/gpio/0");  //Specify request destination
      else
        http.begin("http://192.168.1.100/gpio/1");

      int httpCode = http.GET();                                                                  //Send the request

      if (httpCode &gt; 0) { //Check the returning code

        String payload = http.getString();   //Get the request response payload
        Serial.println(payload);                     //Print the response payload

      }

      http.end();   //Close connection
      return;
    }

    // Wait until the client sends some data
    Serial.println("new client");
    while (!client.available()) {
      delay(1);
    }

    // Read the first line of the request
    String req = client.readStringUntil('\r');
    Serial.println(req);

    // Match the request
    bool toWrite = true;
    if (req.indexOf("/gpio/0") != -1) {
      heldVal = 0;
      b = false;
    }
    else if (req.indexOf("/gpio/1") != -1) {
      heldVal = 1;
      b = true;
    }
    else if (req.indexOf("/mode") != -1) {
      toWrite = false;

      client.flush();

      Serial.println(String(heldVal));
      Serial.println("---in mode request---");

      String input = "{\"mode\":"+String(heldVal)+"}";
      DynamicJsonBuffer jsonBuffer; //----- PROBLEM LINE -----//
      JsonObject&amp; root = jsonBuffer.parseObject(input);

      // Generate the JSON string
      root.printTo(Serial);

      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: application/json");
      client.println("Connection: close");
      client.println();
      root.printTo(client);
      delay(1);
    }
    else {
      Serial.println("invalid request");
      client.stop();
      return;
    }

    // Set GPIO2 according to the request
    if(toWrite) {
      a = true;

      client.flush();

      // Prepare the response
      String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\nGPIO is now ";
      s += (heldVal) ? "high" : "low";
      s += "&lt;/html&gt;\n";

      // Send the response to the client
      client.print(s);
      delay(1);
      Serial.println("Client disonnected");

      // The client will actually be disconnected
      // when the function returns and 'client' object is detroyed
    }
  }
  else {
    ESP.restart();
  }

  delay(30000);    //Send a request every 30 seconds

}
</code></pre>

<p>I put a comment, <code>//----- PROBLEM LINE -----//</code>, next to the problem line  above. The error is:</p>

<pre><code>/Users/eamonwhite/Documents/Arduino/tempcontrolesp/tempcontrolesp.ino: In function 'void loop()':
tempcontrolesp:110: error: 'DynamicJsonBuffer' was not declared in this scope
       DynamicJsonBuffer jsonBuffer;
       ^
tempcontrolesp:110: error: expected ';' before 'jsonBuffer'
       DynamicJsonBuffer jsonBuffer;
                         ^
tempcontrolesp:111: error: 'JsonObject' was not declared in this scope
       JsonObject&amp; root = jsonBuffer.parseObject(input);
       ^
tempcontrolesp:111: error: 'root' was not declared in this scope
       JsonObject&amp; root = jsonBuffer.parseObject(input);
                   ^
tempcontrolesp:111: error: 'jsonBuffer' was not declared in this scope
       JsonObject&amp; root = jsonBuffer.parseObject(input);
                          ^
exit status 1
'DynamicJsonBuffer' was not declared in this scope
</code></pre>

<p>I put it just inside the <code>loop</code> function and it is still giving the same error:</p>

<pre><code>void loop() {
  DynamicJsonBuffer jsonBuffer; //still throws error
</code></pre>

<p>How is it not being used correctly? Its just a declaration...</p>
 27653: <p>Did you forget to include the ArduinoJSON header file:</p>

<pre><code>#include &lt;ArduinoJson.h&gt;
</code></pre>
