title: How to create a json object with hierarchical object and values?
body: <p>How to create a hierarchical JSON object and value structure using Casablanca/cpprestsdk JSON library?</p>
  
  <p>I referred to the following links. But I could not figure out placing the JSON object in another JSON object</p>
  
  <p><a href="https://github.com/Microsoft/cpprestsdk/wiki/JSON" rel="nofollow noreferrer">https://github.com/Microsoft/cpprestsdk/wiki/JSON</a>
  <a href="https://microsoft.github.io/cpprestsdk/namespaceweb_1_1json.html" rel="nofollow noreferrer">https://microsoft.github.io/cpprestsdk/namespaceweb_1_1json.html</a></p>
  
  <h1>JSON Object:</h1>
  
  <pre><code>{
      "employee" :
      {
          "name" : "vinkris",
          "age"  : "30"
      }
  }
  
  {
      struct employee emp;
      string object = U("{") + U("employee:") + U("{") ;
      object += U("name:") + emp.name + U(",") ;
      object += U("age:") + std::to_string(emp.age) + U("}") ;
      json::value = json::value::string(object)
  }
  </code></pre>
  
  <p>Is there any to simplify how the JSON body can be constructed? </p>
  
  <p>For example:</p>
  
  <pre><code>{
      JsonObject object();
      JsonSubObjects subObject();
      subObjects.add("name", "vinkris");
      subObjects.add("age", "30");
      object.add("employee", subObject)
  }
  </code></pre>
  
  <p>I am very new to both <a href="/questions/tagged/c%2b%2b" class="post-tag" title="show questions tagged &#39;c++&#39;" rel="tag">c++</a> and Casablanca library. Wondering if this is possible?</p>
  
  <p>It would be great to get some pointers on how to build something like this.</p>