Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I used rpidjson header-only files in my VC++ (MFC) project to parse json strings.
I Used from this link:
GitHub - Tencent/rapidjson: A fast JSON parser/generator for C++ with both SAX/DOM style API[^]

My problem is unicode characters.
I should set my VC Porject setting to "Use Unicode character set" And json strings containe Unicode characters . So I Use std::wstring to assigned json strings.

But all of rapidjson header files , work with std::string and it's functions.
Is there another header files are worked with std::wstring? (what is it's Link?)

What I have tried:

I want rapidjson header-only files to work with unicode characters (wstring)
Posted
Updated 9-Sep-19 23:59pm

1 solution

I do not think there is need of alternative header files. I am able to make it work as prescribed in RapidJSON documentation - http://rapidjson.org/md_doc_encoding.html.
wstring(wchar_t) is UTF16 in windows so with typedef i am able to use. Here is the code sample:

C++
typedef GenericDocument<UTF16<> > WDocument;
WDocument document;
document.SetObject();
rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
document.AddMember(L"hellooo", 1, allocator);
document[L"hellooo"].SetString(L"rapidjson");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900