Take a look at JSON for Modern C++: <a href="https:&#x2F;&#x2F;github.com&#x2F;nlohmann&#x2F;json" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nlohmann&#x2F;json</a><p>Perhaps this example (benchmark, actually) is close enough:
<a href="https:&#x2F;&#x2F;github.com&#x2F;nlohmann&#x2F;json&#x2F;blob&#x2F;master&#x2F;benchmarks&#x2F;benchmarks.cpp#L47" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nlohmann&#x2F;json&#x2F;blob&#x2F;master&#x2F;benchmarks&#x2F;benc...</a><p>Note that the above also performs mini-benchmark with multiple iterations, dumping parsed data to another file, and finishes with a clean-up of the aforementioned dump target file.<p>The core (read, parse, write) can be simplified to:<p><pre><code>  std::ifstream input_file(&quot;data.json&quot;);
  nlohmann::json data;
  data &lt;&lt; input_file;
  std::cout &lt;&lt; data;</code></pre>