user20587: I am trying to parse JSON using the ArduinoJson library. The problem is that I can’t parse www.read() because it’s declared as a char. I think www.read() needs to be a string? How can I convert www.read() into a format that jsonBufffer.parseObject() can understand? Please excuse any lack of terminology. I am new to using JSON.
When I run the code I get to the point where it prints "-------------------------------------” then it does nothing.
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
#include <ArduinoJson.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,   
ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       "WLAN_SSID_HERE" // cannot be longer than 32    characters!
#define WLAN_PASS       "WLAN_PASS_HERE"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define IDLE_TIMEOUT_MS  300000      // Amount of time to wait (in milliseconds) with no data 
// received before closing the connection.  If you know the server
// you're accessing is quick to respond, you can reduce this value.

// What page to grab!
#define WEBSITE      "wefeel.csiro.au"
#define WEBPAGE      "/api/emotions/primary/totals"


StaticJsonBuffer<200> jsonBuffer;



uint32_t ip;

void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n")); 

  /* Initialise the module */
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }


  Serial.print(F("\nAttempting to connect to ")); 
  Serial.println(WLAN_SSID);
   if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }

  Serial.println(F("Connected!"));

  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  

  /* Display the IP address DNS, Gateway, etc. */
//  while (! displayConnectionDetails()) {
 //    delay(1000);
//  }

  ip = 0;
  // Try looking up the website's IP address
  Serial.print(WEBSITE); 
  Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
   }

  cc3000.printIPdotsRev(ip);

}

void loop(void)
{
  char c;
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
  delay(300);
  if (www.connected()) {
    www.fastrprint(F("GET "));
    www.fastrprint(WEBPAGE);
    www.fastrprint(F(" HTTP/1.1\r\n"));
    www.fastrprint(F("Host: ")); 
    www.fastrprint(WEBSITE); 
    www.fastrprint(F("\r\n"));
    www.fastrprint(F("\r\n"));
    www.println();
  } 
  else {
    Serial.println(F("Connection failed"));    
    return;
  }

  Serial.println(F("-------------------------------------"));

  unsigned long lastRead = millis();
  while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
    //Serial.print(www.available());
    while (www.available()) {
  
  
      //Serial.print(c);
      //char json[] = www.read();
    }
  } 
  c = www.read();
  Serial.print(c);
 JsonObject& root = jsonBuffer.parseObject((char*)c);
 if (!root.success()) {
    Serial.println("parseObject() failed");
    return;
    }

  long love = root["love"];
  long other = root["other"];
  long sadness = root["sadness"];
  long anger = root["anger"];
  long joy = root["joy"];
  long surprise = root["surprise"];
  long fear = root["fear"];

  Serial.println(love);
  Serial.println(other);
  Serial.println(sadness);
  Serial.println(anger);
  Serial.println(joy);
  Serial.println(surprise);
  Serial.println(fear);


  www.stop();
  delay(100);
  www.close();
  delay(200);
 }


user10024: There are two read methods. One that returns a single character (or error), and one that populates a buffer; you want the latter, with method signature int read(char* buf, size_t len) or some such. Read the source. 
When allocating the json buffer in StaticJsonBuffer<200> jsonBuffer;
, make sure your expected json data fit in 200 bytes. 

20587: <p>I am trying to parse JSON using the ArduinoJson library. The problem is that I can’t parse www.read() because it’s declared as a char. I think www.read() needs to be a string? How can I convert www.read() into a format that jsonBufffer.parseObject() can understand? Please excuse any lack of terminology. I am new to using JSON.</p>
<p>When I run the code I get to the point where it prints &quot;-------------------------------------” then it does nothing.</p>
<pre><code>#include &lt;Adafruit_CC3000.h&gt;
#include &lt;ccspi.h&gt;
#include &lt;SPI.h&gt;
#include &lt;string.h&gt;
#include &quot;utility/debug.h&quot;
#include &lt;ArduinoJson.h&gt;

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,   
ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       &quot;WLAN_SSID_HERE&quot; // cannot be longer than 32    characters!
#define WLAN_PASS       &quot;WLAN_PASS_HERE&quot;
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define IDLE_TIMEOUT_MS  300000      // Amount of time to wait (in milliseconds) with no data 
// received before closing the connection.  If you know the server
// you're accessing is quick to respond, you can reduce this value.

// What page to grab!
#define WEBSITE      &quot;wefeel.csiro.au&quot;
#define WEBPAGE      &quot;/api/emotions/primary/totals&quot;


StaticJsonBuffer&lt;200&gt; jsonBuffer;



uint32_t ip;

void setup(void)
{
  Serial.begin(115200);
  Serial.println(F(&quot;Hello, CC3000!\n&quot;)); 

  /* Initialise the module */
  Serial.println(F(&quot;\nInitializing...&quot;));
  if (!cc3000.begin())
  {
    Serial.println(F(&quot;Couldn't begin()! Check your wiring?&quot;));
    while(1);
  }


  Serial.print(F(&quot;\nAttempting to connect to &quot;)); 
  Serial.println(WLAN_SSID);
   if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F(&quot;Failed!&quot;));
    while(1);
  }

  Serial.println(F(&quot;Connected!&quot;));

  /* Wait for DHCP to complete */
  Serial.println(F(&quot;Request DHCP&quot;));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  

  /* Display the IP address DNS, Gateway, etc. */
//  while (! displayConnectionDetails()) {
 //    delay(1000);
//  }

  ip = 0;
  // Try looking up the website's IP address
  Serial.print(WEBSITE); 
  Serial.print(F(&quot; -&gt; &quot;));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &amp;ip)) {
      Serial.println(F(&quot;Couldn't resolve!&quot;));
    }
    delay(500);
   }

  cc3000.printIPdotsRev(ip);

}

void loop(void)
{
  char c;
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
  delay(300);
  if (www.connected()) {
    www.fastrprint(F(&quot;GET &quot;));
    www.fastrprint(WEBPAGE);
    www.fastrprint(F(&quot; HTTP/1.1\r\n&quot;));
    www.fastrprint(F(&quot;Host: &quot;)); 
    www.fastrprint(WEBSITE); 
    www.fastrprint(F(&quot;\r\n&quot;));
    www.fastrprint(F(&quot;\r\n&quot;));
    www.println();
  } 
  else {
    Serial.println(F(&quot;Connection failed&quot;));    
    return;
  }

  Serial.println(F(&quot;-------------------------------------&quot;));

  unsigned long lastRead = millis();
  while (www.connected() &amp;&amp; (millis() - lastRead &lt; IDLE_TIMEOUT_MS)) {
    //Serial.print(www.available());
    while (www.available()) {
  
  
      //Serial.print(c);
      //char json[] = www.read();
    }
  } 
  c = www.read();
  Serial.print(c);
 JsonObject&amp; root = jsonBuffer.parseObject((char*)c);
 if (!root.success()) {
    Serial.println(&quot;parseObject() failed&quot;);
    return;
    }

  long love = root[&quot;love&quot;];
  long other = root[&quot;other&quot;];
  long sadness = root[&quot;sadness&quot;];
  long anger = root[&quot;anger&quot;];
  long joy = root[&quot;joy&quot;];
  long surprise = root[&quot;surprise&quot;];
  long fear = root[&quot;fear&quot;];

  Serial.println(love);
  Serial.println(other);
  Serial.println(sadness);
  Serial.println(anger);
  Serial.println(joy);
  Serial.println(surprise);
  Serial.println(fear);


  www.stop();
  delay(100);
  www.close();
  delay(200);
 }
</code></pre>
 10024: <p>There are two <code>read</code> methods. One that returns a single character (or error), and one that populates a buffer; you want the latter, with method signature <code>int read(char* buf, size_t len)</code> or some such. Read the source. </p>

<p>When allocating the json buffer in <code>StaticJsonBuffer&lt;200&gt; jsonBuffer;
</code>, make sure your expected json data fit in 200 bytes. </p>
