microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.89k stars 1.63k forks source link

Printing a json-array without sorting the keys #1776

Open tellass567 opened 8 months ago

tellass567 commented 8 months ago

Hello, I would like an json-array to be printed unsorted. This is the code to initialize the array

web::json::value array = web::json::value::array();
int i=0;
for (...)
{

   array[i][L"YYY"]=...
   array[i][L"XXX"]=...
   array[i][L"ZZZ"]=...
   ...
   array[i][L"AAA"]=...
   ++i;
}
std::wstringstream ss;
array.serialize(ss);
std::string s= convertWStringToString(ss.str());

The problem is that the json is printed like that: AAA=..,..,XXX=..., YYY=..., ZZZ=... The array is obviously sorted. I want that the array is printed without sorting the keys: YYY=..., XXX=..., ZZZ=..., AAA=...

Any hints?