user72160: I am using ArduinoJson and ESP8266HTTPClient.
Say I have a DynamicJsonDocument that has an unknown number of entries with information on different persons:
[
    {
        "ID": "12345", 
        "name": "John Smith", 
        "Address": "Street 1"
    }, 

    .
    .
    .

    {
        "ID": "00345", 
        "name": "Paul Anderson", 
        "Address": "Street 2"
    }
]


I would like to somehow store the values associated with the key "name" for all the different persons. For example, have something like:
String name1 = "";
...
String nameN = "";

.
.
.

Serial.println(name1);
...
Serial.println(nameN);


To print a list of all the names:
John Smith
Paul Anderson

The only information of the JSON I have beforehand is the keys each entry will have. I do not know how many entries there will be.
How can I go about this?
EDIT: Why I want to do this:
I am using the ESP as a client to get information from a server in the form of a JSON similar to what I wrote above. At the same time, I am serving a simple HTML website by doing server.send(200, "text/html", HTML_code); using the ESP as an AP. I was able to just cram the whole JSON into the HTML as text, but I would like to just have specific information from the JSON, as explained above.
I am aware what I am doing is far from elegant or the "correct way to do it", but I am learning all of this, so any criticism and help is more than welcome :)

user3430: Directly from the ArduinoJson Assistant:
// Stream& input;

StaticJsonDocument<384> doc;
deserializeJson(doc, input);

for (JsonObject elem : doc.as<JsonArray>()) {
  const char* ID = elem["ID"]; // "12345", "13244", "00345"
  const char* name = elem["name"]; // "John Smith", "Jason Statham", "Paul Anderson"
  const char* Address = elem["Address"]; // "Street 1", "Street 2", "Street 3"
}

See also:

How to use ArduinoJson with HTTPClient?
How to deserialize a very large document?


72160: <p>I am using ArduinoJson and ESP8266HTTPClient.</p>
<p>Say I have a DynamicJsonDocument that has an unknown number of entries with information on different persons:</p>
<pre><code>[
    {
        &quot;ID&quot;: &quot;12345&quot;, 
        &quot;name&quot;: &quot;John Smith&quot;, 
        &quot;Address&quot;: &quot;Street 1&quot;
    }, 

    .
    .
    .

    {
        &quot;ID&quot;: &quot;00345&quot;, 
        &quot;name&quot;: &quot;Paul Anderson&quot;, 
        &quot;Address&quot;: &quot;Street 2&quot;
    }
]

</code></pre>
<p>I would like to somehow store the values associated with the key &quot;name&quot; for all the different persons. For example, have something like:</p>
<pre><code>String name1 = &quot;&quot;;
...
String nameN = &quot;&quot;;

.
.
.

Serial.println(name1);
...
Serial.println(nameN);

</code></pre>
<p>To print a list of all the names:</p>
<pre><code>John Smith
Paul Anderson
</code></pre>
<p>The only information of the JSON I have beforehand is the keys each entry will have. I do not know how many entries there will be.</p>
<p>How can I go about this?</p>
<p>EDIT: Why I want to do this:</p>
<p>I am using the ESP as a client to get information from a server in the form of a JSON similar to what I wrote above. At the same time, I am serving a simple HTML website by doing <code>server.send(200, &quot;text/html&quot;, HTML_code);</code> using the ESP as an AP. I was able to just cram the whole JSON into the HTML as text, but I would like to just have specific information from the JSON, as explained above.</p>
<p>I am aware what I am doing is far from elegant or the &quot;correct way to do it&quot;, but I am learning all of this, so any criticism and help is more than welcome :)</p>
 3430: <p>Directly from the <a href="https://arduinojson.org/v6/assistant/" rel="nofollow noreferrer">ArduinoJson Assistant</a>:</p>
<pre class="lang-cpp prettyprint-override"><code>// Stream&amp; input;

StaticJsonDocument&lt;384&gt; doc;
deserializeJson(doc, input);

for (JsonObject elem : doc.as&lt;JsonArray&gt;()) {
  const char* ID = elem[&quot;ID&quot;]; // &quot;12345&quot;, &quot;13244&quot;, &quot;00345&quot;
  const char* name = elem[&quot;name&quot;]; // &quot;John Smith&quot;, &quot;Jason Statham&quot;, &quot;Paul Anderson&quot;
  const char* Address = elem[&quot;Address&quot;]; // &quot;Street 1&quot;, &quot;Street 2&quot;, &quot;Street 3&quot;
}
</code></pre>
<p>See also:</p>
<ul>
<li><a href="https://arduinojson.org/v6/how-to/use-arduinojson-with-httpclient/" rel="nofollow noreferrer">How to use ArduinoJson with HTTPClient?</a></li>
<li><a href="https://arduinojson.org/v6/how-to/deserialize-a-very-large-document/" rel="nofollow noreferrer">How to deserialize a very large document?</a></li>
</ul>
