jsoncpp icon indicating copy to clipboard operation
jsoncpp copied to clipboard

Failed to insert std::string into Json::Value when using MSVC

Open 511844767 opened this issue 1 year ago • 0 comments

Using the test code:

#include <iostream>
#include "json/json.h"

int main()
{
    Json::Value root;
    root["key1"] = "value1";
    root["key2"] = std::string{"value2"};
    std::cout << root << std::endl;
}

When I compile the code with MSVC(Windows SDK 10.0.22621.0, Visual Studio 2022 (v143)), the output is

{
"key1" : "value1",
"key2" : ""
}

But when I comile the code with GCC 10.5.0, the output is

{
        "key1" : "value1",
        "key2" : "value2"
}

I think it is a bug in the MSVC platform.

511844767 avatar Dec 16 '24 05:12 511844767