open-source-parsers / open-source-parsers/jsoncpp

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

Open
#1,587 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
8.9k
Forks
2.7k
Avg merge
31m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided Json::Value insertion example with MSVC and GCC, comparing the output for the literal and std::string assignments. Trace the string-assignment path in the library and add or update a regression test if an implementation issue is found; done when std::string{"value2"} produces "value2" under MSVC.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.