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

Make Value( bool value ) etc explicit

Open
#1,159 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

when passing a Json::Value pointer to a const Json::Value &;
compiler will automatically transform the pointer to bool then to a json::value;

void LogJson(const Json::Value& value) {
  LOG(ERROR) << value.toStyledString();
}
int main() {
  Json::Value json = Json::Value(Json::objectValue)
  const Json::Value *json_p = &json;
  LogJson(json);
  LogJson(json_p);
}

the first LogJson will log a "{}"
the second LogJson will log a "true", caused by implict conversation

Expecte the second LogJson will compile fail.

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

Start at the Json::Value constructors and conversion behavior demonstrated by the LogJson example. Reproduce both calls with the shown snippet, then verify that passing a Json::Value pointer no longer compiles while passing a Json::Value object still does.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.