user63496: I want to parse JSON response from a GET Request. I do this usually by using a String variable to store the response and later parse this string using ArduinoJSON library like shown below:
#include <Arduino.h>
#include "OTA.h"
#include "Credentials.h"
#include <HTTPClient.h>
#include <ArduinoJson.h>

const char url[] = "http://date.jsontest.com/";

HTTPClient getClient;

void getRequest(String &payload)
{
  getClient.begin(url);

  int httpCode = getClient.GET();

  if (httpCode > 0)
  {
    payload = getClient.getString();
    // Serial.print("HTTP Status: ");
    // Serial.println(httpCode);
  }
  else
  {
    Serial.println("Error on HTTP request");
  }
  getClient.end();
}

void parseResponse(String &payload)
{

  StaticJsonDocument<128> doc;

  DeserializationError error = deserializeJson(doc, payload);

  if (error)
  {
    Serial.print("deserializeJson() failed: ");
    Serial.println(error.c_str());
    return;
  }

  const char *time = doc["time"]; // "03:53:25 AM"
  // unsigned long *epoch = doc["milliseconds_since_epoch"]; // 1362196405309
  const char *date = doc["date"]; // "03-02-2013"

  Serial.println(date);
}

void setup()
{
  setupOTA("ESP-N2", mySSID, myPASSWORD);

  Serial.begin(115200);
}

void loop()
{
  ArduinoOTA.handle();

  unsigned long newTime = millis();
  static unsigned long oldTime = 0;
  String payload;

  if (newTime - oldTime >= 5000)
  {
    oldTime = newTime;
    getRequest(payload);
    parseResponse(payload);
    Serial.println();
  }
}

I want to avoid using String and ArduinoJSON offician reference page mentions that it's possible to deserialize directly from input Stream e.g. wifiClient, ethernetclient or serial but I couldn't find any example showing it's usage. So I am curious to learn how to use it.
From my basic understanding of a Stream, I suppose I need define a buffer or memory location that will hold the incoming bytes and using the address of this buffer need to read data bit by bit. So  do I need to do something like this:
char buffer[]= httpClient.getStream();

and then pass this buffer as input to deserialize function? or have I gotten it completely wrong?

user3430: httpClient.getStream() returns an instance of Stream that you can pass to deserializeJson(), like so:
deserializeJson(doc, httpClient.getStream());

However, by doing so, you bypass the code in HTTPClient that handles chunked transfer encoding, so you must call httpClient.useHTTP10(true) before calling GET to make sure the server won't return a chunked response.
See How to use ArduinoJson with HTTPClient?

63496: <p>I want to parse JSON response from a GET Request. I do this usually by using a String variable to store the response and later parse this string using ArduinoJSON library like shown below:</p>
<pre><code>#include &lt;Arduino.h&gt;
#include &quot;OTA.h&quot;
#include &quot;Credentials.h&quot;
#include &lt;HTTPClient.h&gt;
#include &lt;ArduinoJson.h&gt;

const char url[] = &quot;http://date.jsontest.com/&quot;;

HTTPClient getClient;

void getRequest(String &amp;payload)
{
  getClient.begin(url);

  int httpCode = getClient.GET();

  if (httpCode &gt; 0)
  {
    payload = getClient.getString();
    // Serial.print(&quot;HTTP Status: &quot;);
    // Serial.println(httpCode);
  }
  else
  {
    Serial.println(&quot;Error on HTTP request&quot;);
  }
  getClient.end();
}

void parseResponse(String &amp;payload)
{

  StaticJsonDocument&lt;128&gt; doc;

  DeserializationError error = deserializeJson(doc, payload);

  if (error)
  {
    Serial.print(&quot;deserializeJson() failed: &quot;);
    Serial.println(error.c_str());
    return;
  }

  const char *time = doc[&quot;time&quot;]; // &quot;03:53:25 AM&quot;
  // unsigned long *epoch = doc[&quot;milliseconds_since_epoch&quot;]; // 1362196405309
  const char *date = doc[&quot;date&quot;]; // &quot;03-02-2013&quot;

  Serial.println(date);
}

void setup()
{
  setupOTA(&quot;ESP-N2&quot;, mySSID, myPASSWORD);

  Serial.begin(115200);
}

void loop()
{
  ArduinoOTA.handle();

  unsigned long newTime = millis();
  static unsigned long oldTime = 0;
  String payload;

  if (newTime - oldTime &gt;= 5000)
  {
    oldTime = newTime;
    getRequest(payload);
    parseResponse(payload);
    Serial.println();
  }
}
</code></pre>
<p>I want to avoid using String and <a href="https://arduinojson.org/" rel="nofollow noreferrer">ArduinoJSON offician reference</a> page mentions that it's possible to deserialize directly from input Stream e.g. wifiClient, ethernetclient or serial but I couldn't find any example showing it's usage. So I am curious to learn how to use it.</p>
<p>From my basic understanding of a Stream, I suppose I need define a buffer or memory location that will hold the incoming bytes and using the address of this buffer need to read data bit by bit. So  do I need to do something like this:</p>
<pre><code>char buffer[]= httpClient.getStream();
</code></pre>
<p>and then pass this buffer as input to deserialize function? or have I gotten it completely wrong?</p>
 3430: <p><code>httpClient.getStream()</code> returns an instance of <a href="https://www.arduino.cc/reference/en/language/functions/communication/stream/" rel="nofollow noreferrer"><code>Stream</code></a> that you can pass to <a href="https://arduinojson.org/v6/api/json/deserializejson/" rel="nofollow noreferrer"><code>deserializeJson()</code></a>, like so:</p>
<pre class="lang-cpp prettyprint-override"><code>deserializeJson(doc, httpClient.getStream());
</code></pre>
<p>However, by doing so, you bypass the code in <code>HTTPClient</code> that handles <a href="https://en.wikipedia.org/wiki/Chunked_transfer_encoding" rel="nofollow noreferrer">chunked transfer encoding</a>, so you must call <code>httpClient.useHTTP10(true)</code> before calling <code>GET</code> to make sure the server won't return a chunked response.</p>
<p>See <a href="https://arduinojson.org/v6/how-to/use-arduinojson-with-httpclient/" rel="nofollow noreferrer">How to use ArduinoJson with HTTPClient?</a></p>
