title: Converting json object to c++ object
body: <p>I'm sending json object from python to c++ program using http, for this example the object is built like so:</p>
  
  <pre><code>{
  "id":1,
  "parameters":{
                "var1":"bla",
                "var2":7,
                "var3":/* base64 encoded binary data */
               }
  }
  </code></pre>
  
  <p>The c++ code knows that if <code>"id" == 1</code> then we have three parameters first one is <code>std::string</code> second is <code>int</code> and third is <code>vector&lt;unsigned char&gt;</code>. (or <code>char[],int,unsigned char[]</code>)</p>
  
  <p>if the <code>id</code> is different then different variable types are sent. each <code>id</code> corresponds to different C++ Class that have different variable types.</p>
  
  <p>I'm thinking that I should send a struct containing all the values of the parameters from the json like so:</p>
  
  <pre><code>{
   char var1[MAX_SIZE];
   int var2;
   unsigned char var3[MAX_SIZE];
  }
  </code></pre>
  
  <p>the struct byte array will be encoded in base64, but I dont want to limit the data sent with <code>MAX_SIZE</code></p>
  
  <p>What are the methods/designs it is possible to use in this situation if I want to "cast" each value from the json to objects that c++ can use?</p>