title: C++ Pass JSON object to string - jsoncpp
body: <p>I have a code that pass a json data to a function by pointer of void. This code works with a json string. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  struct funcInputs{
    bool bVolume;
    std::string data;
  
    void read() {  
      std::cout&lt;&lt;" userdata: "&lt;&lt;data&lt;&lt;std::endl;  
    };
  };
  void test(void *input)  {
  
     //Read input
     funcInputs *inputVar = (reinterpret_cast&lt; funcInputs *&gt; (input));
     inputVar-&gt;read();
  
   }
  int main()
  {
  
     std::string s= "{\"lowerThreshold\":200,\"upperThreshold\":1080}";
     funcInputs arg ={true,s};
     test(reinterpret_cast&lt;void *&gt;(&amp;arg));
  }
  </code></pre>
  
  <p>It prints the result: </p>
  
  <pre><code>userdata: {"lowerThreshold":200,"upperThreshold":1080}
  </code></pre>
  
  <p>Now if my json is an object, like this: </p>
  
  <pre><code>{"lowerThreshold":200,"upperThreshold":1080}
  </code></pre>
  
  <p>While passing json object to string, I used the below code </p>
  
  <pre><code>  Json::StreamWriterBuilder builder;
    builder.settings_["indentation"] = "";
    std::string s = Json::writeString(builder, jsonObj);
    funcInputs arg ={true,s};
    test(reinterpret_cast&lt;void *&gt;(&amp;arg));
  </code></pre>
  
  <p>And this give me a bad result: </p>
  
  <pre><code>userdata: ���hreshold":200,"upperThreshold":1080}
  </code></pre>
  
  <p>Can you help me correct this error?</p>