cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Printing a json-array without sorting the keys

Open tellass567 opened this issue 2 years ago • 0 comments

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?

tellass567 avatar Nov 03 '23 10:11 tellass567