Getting Json from URL and Displaying data

Hey I'm using HttpClient and Arduino Json Lib .
My code look like that:

#include <ArduinoJson.h>
#include <Bridge.h>
#include <HttpClient.h>


void setup() {
  Bridge.begin();


   HttpClient client;

  // Make a HTTP request:
  client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");
 while(client.available()){
  char c = client.read();
  

char json[] = c;
  }
//
// Step 1: Reserve memory space
//
StaticJsonBuffer<200> jsonBuffer;

//
// Step 2: Deserialize the JSON string
//
JsonObject& root = jsonBuffer.parseObject(json);
if (!root.success())
{
  Serial.println("parseObject() failed");
  return;
}

//
// Step 3: Retrieve the values
//
const char* sensor    = root["status"];
Serial.print(sensor);
}

void loop() {
  // Initialize the client library
 
}

Website http://18003.hosts.ma-cloud.nl/light/lightStatus.php

Give me following json:

{\"id\":\"1\",\"status\":\"0\"},{\"id\":\"2\",\"status\":\"1\"},{\"id\":\"3\",\"status\":\"0\"},{\"id\":\"4\",\"status\":\"1\"}

If I assign json data to variable like that:
char json[] = "{"id":"1","status":"0"},{"id":"2","status":"1"},{"id":"3","status":"0"},{"id":"4","status":"1"}";

It works correctly.

But if I want to get it from the url so not hardcoded.
When i use:

char json[] = c;

I get following error:

C:\Users\Artur\Desktop\XlabJson\XlabJson.ino: In function 'void setup()':

XlabJson:28: error: 'json' was not declared in this scope

 JsonObject& root = jsonBuffer.parseObject(json);

                                           ^

exit status 1
'json' was not declared in this scope

Please Help !! Deadline is comming :frowning:

Deadline is comming

Bummer. Too bad you are not going to have enough time to learn about pointers and arrays and the relationship between them in time.

   char *stupidJSONcrap = client.get("someStupidURLThatReturnsJSONCrap");

Yea...

Thanks for answer, I'm a real new in C and Arduino, I know PHP,Python well....
I tryed to use your answer to make it right but It does not work.

client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");

Return 1 , I need to use second function :

  char c = client.read();

to get currect json from url. So your answer won't help me? Of am I wrong?

I tryed to use your answer to make it right but It does not work.

All of your code is where?

If you are going to read the response one character at a time, you'll need to determine a maximum number of characters that can reasonably be in a response, and allocate an array that size to store the data in. Then, read and store each character, in the appropriate position, followed by a NULL.

You were the one that suggested that client.get() returned an array of data.

How should It look like. I really don't get it...

I tryed to do it like that:

   HttpClient client;

  // Make a HTTP request:
  client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");
  char *stupidJSONcrap = client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");

 client.available();
  char c = client.read();
  char json[] = stupidJSONcrap;

Also tryed:

  client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");
  char *stupidJSONcrap = client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");

 client.available();
  char c = stupidJSONcrap.read();
  char json[] = c;
//

I was trying to use your answer all the way but still I get some errors...

client.get("http://18003.hosts.ma-cloud.nl/light/lightStatus.php");

int index = 0;
char uselessJSONCrap[120];
while(client.connected())
{
   while(client.available() > 0 && index < 118)
   {
      uselessJSONCrap[index++] = client.read();
      uselessJSONCrap[inex] = '\0';
   }
}

parseUselessJSONCrap(uselessJSONCrap);

If you get the impression that I do not care for JSON, you are correct. Unreadable crap that has no advantage over XML.

What do you mean with

parseUselessJSONCrap(uselessJSONCrap);