wangxiaowei0303 / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

'Convert JSON document to string' PROBLEM solved... #112

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am using the lib(ver 0.11) in windows(7 64bit).

Problem occured while I want to using below code:

   //Document doc;
   GenericDocument<UTF16<> > doc;
   doc.SetObject();
   doc.AddMember(_T("String"), _T("StringValue"), doc.GetAllocator());
   // Convert JSON document to string
   GenericStringBuffer< UTF16<> > buffer;
   Writer< GenericStringBuffer< UTF16<> >, UTF16<> > writer(buffer);
   doc.Accept(writer);
   const wchar_t* strJson = buffer.GetString();

Above code can compile with update stringbuffer.h in rapidjson lib:

  ORIGINAL(with BUG):

    const char* GetString() const {
        // Push and pop a null terminator. This is safe.
        *stack_.template Push<Ch>() = '\0';
        stack_.template Pop<Ch>(1);

        return stack_.template Bottom<Ch>();
    }

  UPDATE(BUG FIXED):

    const Ch* GetString() const {
        // Push and pop a null terminator. This is safe.
        *stack_.template Push<Ch>() = '\0';
        stack_.template Pop<Ch>(1);

        return stack_.template Bottom<Ch>();
    }

Thanks for the lovely lib :)

Original issue reported on code.google.com by hassansh...@gmail.com on 5 Jul 2014 at 6:57

GoogleCodeExporter commented 8 years ago
Please note the development of RapidJSON has been moved to GitHub 
https://github.com/miloyip/rapidjson
This has been already been fixed in the Github master branch.
Anyway, thank you for your support.

Original comment by milo...@gmail.com on 5 Jul 2014 at 7:55