Skip to content

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

@chen3feng

Description

@chen3feng

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions