Tencent / Tencent/flare

jsoncpp: modernize Reader/Writer to the 1.x builder API (post-vcpkg-migration)

Open
#192 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.4k
Forks
208
PR merge metrics
No merged PRs in 30d

Description

Follow-up to the jsoncpp vcpkg migration (#179). The migration is done in two steps:

  • Step 1 (vcpkg move): migrate //thirdparty/jsoncpp to vcpkg jsoncpp 1.9.x, keeping flare's existing Json::Reader/FastWriter/StyledWriter usage and silencing their deprecation with -Wno-deprecated-declarations on the consuming targets. This isolates the library/version change from any API rewrite.
  • Step 2 (this issue): replace the deprecated APIs with the 1.x builder API so we can drop the warning suppression (and stay compatible past jsoncpp's eventual removal of the legacy classes).

Scope

Deprecated APIs are used in ~23 files / ~12 targets (http builtin handlers, binlog, base/option, monitoring, plus tests):

  • Json::Reader (≈21 sites) → Json::CharReaderBuilder + Json::parseFromStream / CharReader::parse.
  • Json::FastWriter (≈4) / Json::StyledWriter (≈8) → Json::StreamWriterBuilder + Json::writeString.

Behavioral pitfalls to handle in the rewrite

  • FastWriter::write() appends a trailing \n; writeString() does not. StreamWriterBuilder defaults to pretty output — set builder["indentation"]="" for compact. Update golden/string-compare tests accordingly.
  • 1.x throws Json::LogicError/RuntimeError on type misuse (e.g. asString() on a non-string) where 0.x coerced/defaulted.
  • 1.x parsing is stricter; revisit any inputs relying on 0.x leniency.

Optional cleanup

  • Switch includes from flare's jsoncpp/<h> alias to the canonical json/<h> and drop the include_prefix={'jsoncpp':'json'} mapping added in Step 1.

🤖 Generated with Claude Code

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

Locate the deprecated Json::Reader, FastWriter, and StyledWriter uses across the http builtin handlers, binlog, base/option, monitoring, and tests. Start by tracing each use and its existing string or golden-test expectations. Replace the APIs with the 1.x builders, preserve compact output and trailing-newline behavior, update affected comparisons, and verify the warning suppression can be removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.