I'm testing a piece of code to see if I can parse the JSON code I'm receiving. I basically copied the code from: ArduinoJson/assistant
So I've placed the received JSON string in a const char*
to see if it works, but I get a weird response instead of a normal integer result. Does somebody know what is going on here?
PS I know it's a huge response from the server, while I only need like 2 data's from.
Here's my code:
#include <ArduinoJson.h>
void setup() {
Serial.begin(115200);
Serial.println("Hello");
DynamicJsonBuffer jsonBuffer(10833);
//Serial.println("Buffer" + bufferSize);
const char* json = "{\"devices\":{\"thermostats\":{\"e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU\":{\"humidity\":40,\"locale\":\"nl-NL\",\"temperature_scale\":\"C\",\"is_using_emergency_heat\":false,\"has_fan\":false,\"software_version\":\"5.6.6-4\",\"has_leaf\":true,\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7XyH-9WDdVgA\",\"device_id\":\"e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU\",\"name\":\"Downstairs\",\"can_heat\":true,\"can_cool\":false,\"target_temperature_c\":13.5,\"target_temperature_f\":57,\"target_temperature_high_c\":24,\"target_temperature_high_f\":75,\"target_temperature_low_c\":20,\"target_temperature_low_f\":68,\"ambient_temperature_c\":18,\"ambient_temperature_f\":65,\"away_temperature_high_c\":24,\"away_temperature_high_f\":76,\"away_temperature_low_c\":8.5,\"away_temperature_low_f\":48,\"eco_temperature_high_c\":24,\"eco_temperature_high_f\":76,\"eco_temperature_low_c\":8.5,\"eco_temperature_low_f\":48,\"is_locked\":false,\"locked_temp_min_c\":20,\"locked_temp_min_f\":68,\"locked_temp_max_c\":22,\"locked_temp_max_f\":72,\"sunlight_correction_active\":false,\"sunlight_correction_enabled\":true,\"structure_id\":\"vEJb634MNif-xVxcn3hIdIAAdT2p5L7beo2amUiTuBVoEPy3C0PAFw\",\"fan_timer_active\":false,\"fan_timer_timeout\":\"1970-01-01T00:00:00.000Z\",\"fan_timer_duration\":15,\"previous_hvac_mode\":\"\",\"hvac_mode\":\"heat\",\"time_to_target\":\"~0\",\"time_to_target_training\":\"ready\",\"where_name\":\"Downstairs\",\"label\":\"\",\"name_long\":\"Downstairs Thermostat\",\"is_online\":true,\"last_connection\":\"2018-02-15T20:27:29.319Z\",\"hvac_state\":\"off\"}}},\"structures\":{\"NzsPBklZNQBC4FVqmRUaVLqMhPVJII3IzQ0QfhReeGv_UCagNdtMhg\":{\"name\":\"Structure 1\",\"country_code\":\"US\",\"time_zone\":\"America/Los_Angeles\",\"away\":\"home\",\"structure_id\":\"NzsPBklZNQBC4FVqmRUaVLqMhPVJII3IzQ0QfhReeGv_UCagNdtMhg\",\"wheres\":{\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6FUQ2RVTLC5w\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6FUQ2RVTLC5w\",\"name\":\"Backyard\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4POqHyZw5GHQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4POqHyZw5GHQ\",\"name\":\"Basement\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5QjU1FA_slkA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5QjU1FA_slkA\",\"name\":\"Bedroom\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5kuu8P9K1TFQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5kuu8P9K1TFQ\",\"name\":\"Den\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4ncylMQyZn-g\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4ncylMQyZn-g\",\"name\":\"Dining Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7XyH-9WDdVgA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7XyH-9WDdVgA\",\"name\":\"Downstairs\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5rtDphaQytaQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5rtDphaQytaQ\",\"name\":\"Driveway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5Z5XxmZr9Aeg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5Z5XxmZr9Aeg\",\"name\":\"Entryway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7r62EA7u7DWw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7r62EA7u7DWw\",\"name\":\"Family Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6o_Kr6tv-CSA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6o_Kr6tv-CSA\",\"name\":\"Front Yard\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5OO0kfgPRADw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5OO0kfgPRADw\",\"name\":\"Guest House\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5AMihmAgobTw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5AMihmAgobTw\",\"name\":\"Guest Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6MLDlLEu4-2A\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6MLDlLEu4-2A\",\"name\":\"Hallway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5t08bO8j0Mzg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5t08bO8j0Mzg\",\"name\":\"Kids Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7p1ASlDNUnHg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7p1ASlDNUnHg\",\"name\":\"Kitchen\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7uLdRQIIIvww\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7uLdRQIIIvww\",\"name\":\"Living Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5W7d3KtKxzfg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5W7d3KtKxzfg\",\"name\":\"Master Bedroom\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6arlkBKu_K8Q\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6arlkBKu_K8Q\",\"name\":\"Office\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7gc73riRgkvw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7gc73riRgkvw\",\"name\":\"Outside\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6c07Ca7PZt2A\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6c07Ca7PZt2A\",\"name\":\"Upstairs\"}}},\"vEJb634MNif-xVxcn3hIdIAAdT2p5L7beo2amUiTuBVoEPy3C0PAFw\":{\"name\":\"CNT/FAI\",\"country_code\":\"BE\",\"time_zone\":\"Europe/Brussels\",\"away\":\"home\",\"thermostats\":[\"e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU\"],\"structure_id\":\"vEJb634MNif-xVxcn3hIdIAAdT2p5L7beo2amUiTuBVoEPy3C0PAFw\",\"wheres\":{\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6FUQ2RVTLC5w\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6FUQ2RVTLC5w\",\"name\":\"Backyard\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4POqHyZw5GHQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4POqHyZw5GHQ\",\"name\":\"Basement\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5QjU1FA_slkA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5QjU1FA_slkA\",\"name\":\"Bedroom\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5kuu8P9K1TFQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5kuu8P9K1TFQ\",\"name\":\"Den\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4ncylMQyZn-g\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG4ncylMQyZn-g\",\"name\":\"Dining Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7XyH-9WDdVgA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7XyH-9WDdVgA\",\"name\":\"Downstairs\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5rtDphaQytaQ\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5rtDphaQytaQ\",\"name\":\"Driveway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5Z5XxmZr9Aeg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5Z5XxmZr9Aeg\",\"name\":\"Entryway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7r62EA7u7DWw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7r62EA7u7DWw\",\"name\":\"Family Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6o_Kr6tv-CSA\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6o_Kr6tv-CSA\",\"name\":\"Front Yard\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5OO0kfgPRADw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5OO0kfgPRADw\",\"name\":\"Guest House\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5AMihmAgobTw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5AMihmAgobTw\",\"name\":\"Guest Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6MLDlLEu4-2A\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6MLDlLEu4-2A\",\"name\":\"Hallway\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5t08bO8j0Mzg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5t08bO8j0Mzg\",\"name\":\"Kids Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7p1ASlDNUnHg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7p1ASlDNUnHg\",\"name\":\"Kitchen\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7uLdRQIIIvww\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7uLdRQIIIvww\",\"name\":\"Living Room\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5W7d3KtKxzfg\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG5W7d3KtKxzfg\",\"name\":\"Master Bedroom\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6arlkBKu_K8Q\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6arlkBKu_K8Q\",\"name\":\"Office\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7gc73riRgkvw\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG7gc73riRgkvw\",\"name\":\"Outside\"},\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6c07Ca7PZt2A\":{\"where_id\":\"YygkopgUUc_cIFnCNG7GRDIIQnENO0ScVx9Pa78qfG6c07Ca7PZt2A\",\"name\":\"Upstairs\"}}}},\"metadata\":{\"access_token\":\"c.zxxx\",\"client_version\":2,\"user_id\":\"z.1.1.EdSQPfAYvEeh8u6g2NyARyancELYiLqqn77VnzioUvo=\"}}";
JsonObject& root = jsonBuffer.parseObject(json);
JsonObject& devices_thermostats_e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU = root["devices"]["thermostats"]["e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU"];
float setPoint = devices_thermostats_e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU["target_temperature_c"];
int ambTemp = devices_thermostats_e97ayjdpIOkPa4vZFxHggZMXiHKfhsyU["ambient_temperature_c"];
Serial.println("ambTemp:" + ambTemp);
}
void loop() {
// put your main code here, to run repeatedly:
}
The serial monitor gives me this result:
Hello
@( @( @( @( @