title: How to create a json object from scratch in c++ using picojson.h
body: <p>Trying to serialize a class I have into a json string. Of course I can just write the strings manually, but I was hoping to utilize a the <strong>picojson</strong> library.</p>
  <p>What I am trying to achieve is, given this class A</p>
  <pre><code>class A {
    public:
      int field1;
      string field2;
  }
  
  A a;
  a.field1 = 1;
  a.field2 = &quot;example&quot;;
  </code></pre>
  <p>I want to convert this class instance &quot;a&quot; into a picojson object and then call picojson::serialize() to get the json string.</p>
  <pre><code>{&quot;field1&quot;: 1, &quot;field2&quot;: &quot;example&quot;}
  </code></pre>