From 7a4bc046abf69660393ece2e831bebc9abc7313d Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Mon, 21 Mar 2016 10:21:30 +0100 Subject: [PATCH] improve json output structure --- things.ino | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/things.ino b/things.ino index 2adbf5d..64e71ec 100644 --- a/things.ino +++ b/things.ino @@ -385,12 +385,14 @@ void setup() { read_sensor(); DynamicJsonBuffer jsonBuffer; JsonObject& json = jsonBuffer.createObject(); - json["mqtt_server"] = mqtt_server; - json["mqtt_port"] = mqtt_port; - json["mqtt_topic"] = mqtt_topic; - json["temperature"] = str_temperature; - json["humidity"] = str_humidity; - json["heatindex"] = str_heatindex; + JsonObject& mqtt = json.createNestedObject("mqtt"); + mqtt["server"] = mqtt_server; + mqtt["port"] = mqtt_port; + mqtt["topic"] = mqtt_topic; + JsonObject& dht = json.createNestedObject("dht"); + dht["temperature"] = str_temperature; + dht["humidity"] = str_humidity; + dht["heatindex"] = str_heatindex; String response; json.printTo(response); http_server.send(200, "text/plain", response);