user88129: I have a vector which consist of a struct, see below:
struct FileInformation
  {
    String name;
    size_t filesize;
  };
    
std::vector<FileInformation> FileInformations;

How do I get JSON out of it the easiest way?

user3430: Using ArduinoJson:
DynamicJsonDocument doc(2048);
for (const FileInformation& item : FileInformations) {
  JsonObject& obj = doc.createNestedObject();
  obj["name"] = item.name;
  obj["filesize"] = item.filesize;
}
serializeJson(doc, Serial);

This will produce a JSON document that looks like this:
[
  {"name": "command.com", "filesize": 1234},
  {"name": "config.sys", "filesize": 2345},
  {"name": "autoexec.bat", "filesize": 3456}
]

Please read the tutorial for more information.

88129: <p>I have a vector which consist of a struct, see below:</p>
<pre class="lang-cpp prettyprint-override"><code>struct FileInformation
  {
    String name;
    size_t filesize;
  };
    
std::vector&lt;FileInformation&gt; FileInformations;
</code></pre>
<p>How do I get JSON out of it the easiest way?</p>
 3430: <p>Using <a href="https://arduinojson.org" rel="nofollow noreferrer">ArduinoJson</a>:</p>
<pre class="lang-cpp prettyprint-override"><code>DynamicJsonDocument doc(2048);
for (const FileInformation&amp; item : FileInformations) {
  JsonObject&amp; obj = doc.createNestedObject();
  obj[&quot;name&quot;] = item.name;
  obj[&quot;filesize&quot;] = item.filesize;
}
serializeJson(doc, Serial);
</code></pre>
<p>This will produce a JSON document that looks like this:</p>
<pre class="lang-cpp prettyprint-override"><code>[
  {&quot;name&quot;: &quot;command.com&quot;, &quot;filesize&quot;: 1234},
  {&quot;name&quot;: &quot;config.sys&quot;, &quot;filesize&quot;: 2345},
  {&quot;name&quot;: &quot;autoexec.bat&quot;, &quot;filesize&quot;: 3456}
]
</code></pre>
<p>Please read <a href="https://arduinojson.org/v6/doc/serialization/" rel="nofollow noreferrer">the tutorial</a> for more information.</p>
