title: How to create and parse hierarchical/nested JSON with Poco C++?
body: <p>Edited to simplify and show my EXACT code.</p>
  
  <p>I have the following data that I need to serialize to JSON as well as parse from JSON.</p>
  
  <pre><code>string name;
  std::map&lt;string, string&gt; metaData;
  </code></pre>
  
  <p>I need the JSON to be nested/hierarchical like this:</p>
  
  <pre><code>{
      "name":"john smith"
      "metadata":
      {
          "age":45,
          "middle_name":"william",
      },
  }
  </code></pre>
  
  <p>Here is my EXACT code:</p>
  
  <pre><code>void DeserializeFromJSON(string &amp;jsonString)
  {
      // Parse the JSON
      Poco::JSON::Parser jsonParser;
      Poco::Dynamic::Var parsedJSON = jsonParser.parse(jsonString);
      Poco::Dynamic::Var parsedResult = jsonParser.result();
  
      // Extract the JSON Object
      Poco::DynamicStruct jsonStruct = *parsedResult.extract&lt;Poco::JSON::Object::Ptr&gt;();
  
      // Get the name
      name = jsonStruct["name"].toString();
  
      // Get the meta data -- which of these should I use???
      Poco::Dynamic::Var metaVar = jsonStruct["metadata"];
      Poco::JSON::Object metaObj = jsonStruct["metadata"];
  
      // At this point, exactly what is it I have in 'metaVar' and 'metaObj'?
  
      // If I try to loop like you say, I get compiler error C2664 in "var.h"
      for (Poco::JSON::Object::ConstIterator itr = jsonObject.begin(), end = jsonObject.end(); itr != end; ++itr)
      {
          string metaName = itr-&gt;first;
          string metaValue = itr-&gt;second.toString();
      }
  }
  </code></pre>