title: C++ std::vector to JSON Array with rapidjson
body: <p>I am trying to parse a basic std::vector of strings to json using the rapidjson library.</p>
  
  <p>Even though there are multiple answers to this question online, none of it worked for me. The best I could find was <a href="https://discuss.cocos2d-x.org/t/solved-how-to-write-json-array-using-rapidjson/29551/2" rel="nofollow noreferrer">this</a>, but I do get an error (cleaned up a bit):</p>
  
  <blockquote>
    <p>Error C2664   'noexcept': cannot convert argument 1 from 'std::basic_string,std::allocator>' to 'rapidjson::GenericObject,rapidjson::MemoryPoolAllocator>>'</p>
  </blockquote>
  
  <p>My code is mostly based on the link above:</p>
  
  <pre class="lang-c++ prettyprint-override"><code>rapidjson::Document d;
  std::vector&lt;std::string&gt; files;
  
  // The Vector gets filled with filenames,
  // I debugged this and it works without errors.
  for (const auto &amp; entry : fs::directory_iterator(UPLOAD_DIR))
      files.push_back(entry.path().string());
  
  // This part is based on the link provided
  d.SetArray();
  
  rapidjson::Document::AllocatorType&amp; allocator = d.GetAllocator();
  for (int i = 0; i &lt; files.size(); i++) {
      d.PushBack(files.at(i), allocator);
  }
  rapidjson::StringBuffer strbuf;
  rapidjson::Writer&lt;rapidjson::StringBuffer&gt; writer(strbuf);
  d.Accept(writer);
  
  jsonString = strbuf.GetString();
  </code></pre>
  
  <p>It would be nice if someone could explain what I am missing here, as I do not fully understand the error showing up. I guess it has to do something with the provided string types, but the error is generated in a Rapidjson file..</p>
  
  <p>I also would appreciate if there were other working examples you could provide.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong>
  With JSON Array I mean just a basic json string containing the values of the vector.</p>