user27363: I am learning the ArduinoJson.h library and creating jsonOject:
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
  JsonObject& root = jsonBuffer.createObject();
  JsonArray& tempValues = root.createNestedArray("temperature");
  tempValues.add(t);
  JsonArray& humiValues = root.createNestedArray("humidity");
  humiValues.add(h);
  JsonArray& dewpValues = root.createNestedArray("dewpoint");
  dewpValues.add(pfDew);
  JsonArray& EsPvValues = root.createNestedArray("systemv");
  EsPvValues.add(pfVcc / 1000, 3);
  return root;
}

As per the example given here. However since I am using an ESP8266WebServer to create a server object from ESP8266WebServer.h, I cannot pass a JsonObject to server.send(.....).

no matching function for call to 'ESP8266WebServer::send(int, const
  char [10], ArduinoJson::JsonObject&)'

void outputJson() {
  StaticJsonBuffer<500> jsonBuffer;
  JsonObject& json = prepareResponse(jsonBuffer);
  writeResponse(client, json);
  server.send ( 200, "text/json", json );
}

void writeResponse(WiFiClient& clnt, JsonObject& json) {
  clnt.println("HTTP/1.1 200 OK");
  clnt.println("Content-Type: application/json");
  clnt.println("Access-Control-Allow-Origin: *");
  clnt.println("Connection: close");
  clnt.println();
  json.prettyPrintTo(clnt);
}


user3430: As far as I know, the only way is to serialize the JsonObject to a String:
String createJsonResponse() {
  StaticJsonBuffer<500> jsonBuffer;

  JsonObject &root = jsonBuffer.createObject();
  JsonArray &tempValues = root.createNestedArray("temperature");
  tempValues.add(t);
  JsonArray &humiValues = root.createNestedArray("humidity");
  humiValues.add(h);
  JsonArray &dewpValues = root.createNestedArray("dewpoint");
  dewpValues.add(pfDew);
  JsonArray &EsPvValues = root.createNestedArray("systemv");
  EsPvValues.add(pfVcc / 1000, 3);

  String json;
  root.prettyPrintTo(json);
  return json;
}

void outputJson() {
    server.send(200, "text/json", createJsonResponse());
}

By the way, I recommend that you use the ArduinoJson Assistant to compute the size of the JsonBuffer.

27363: <p>I am learning the <code>ArduinoJson.h</code> library and creating jsonOject:</p>

<pre><code>JsonObject&amp; prepareResponse(JsonBuffer&amp; jsonBuffer) {
  JsonObject&amp; root = jsonBuffer.createObject();
  JsonArray&amp; tempValues = root.createNestedArray("temperature");
  tempValues.add(t);
  JsonArray&amp; humiValues = root.createNestedArray("humidity");
  humiValues.add(h);
  JsonArray&amp; dewpValues = root.createNestedArray("dewpoint");
  dewpValues.add(pfDew);
  JsonArray&amp; EsPvValues = root.createNestedArray("systemv");
  EsPvValues.add(pfVcc / 1000, 3);
  return root;
}
</code></pre>

<p>As per the example given <a href="http://www.esp8266.com/viewtopic.php?p=36531#p36531" rel="nofollow noreferrer">here</a>. However since I am using an <code>ESP8266WebServer</code> to create a server object from <code>ESP8266WebServer.h</code>, I cannot pass a JsonObject to <code>server.send(.....)</code>.</p>

<blockquote>
  <p>no matching function for call to 'ESP8266WebServer::send(int, const
  char [10], ArduinoJson::JsonObject&amp;)'</p>
</blockquote>

<pre><code>void outputJson() {
  StaticJsonBuffer&lt;500&gt; jsonBuffer;
  JsonObject&amp; json = prepareResponse(jsonBuffer);
  writeResponse(client, json);
  server.send ( 200, "text/json", json );
}

void writeResponse(WiFiClient&amp; clnt, JsonObject&amp; json) {
  clnt.println("HTTP/1.1 200 OK");
  clnt.println("Content-Type: application/json");
  clnt.println("Access-Control-Allow-Origin: *");
  clnt.println("Connection: close");
  clnt.println();
  json.prettyPrintTo(clnt);
}
</code></pre>
 3430: <p>As far as I know, the only way is to serialize the <code>JsonObject</code> to a <code>String</code>:</p>

<pre><code>String createJsonResponse() {
  StaticJsonBuffer&lt;500&gt; jsonBuffer;

  JsonObject &amp;root = jsonBuffer.createObject();
  JsonArray &amp;tempValues = root.createNestedArray("temperature");
  tempValues.add(t);
  JsonArray &amp;humiValues = root.createNestedArray("humidity");
  humiValues.add(h);
  JsonArray &amp;dewpValues = root.createNestedArray("dewpoint");
  dewpValues.add(pfDew);
  JsonArray &amp;EsPvValues = root.createNestedArray("systemv");
  EsPvValues.add(pfVcc / 1000, 3);

  String json;
  root.prettyPrintTo(json);
  return json;
}

void outputJson() {
    server.send(200, "text/json", createJsonResponse());
}
</code></pre>

<p>By the way, I recommend that you use the <a href="https://arduinojson.org/assistant/" rel="nofollow noreferrer">ArduinoJson Assistant</a> to compute the size of the <code>JsonBuffer</code>.</p>
