Skip to content

Add production native JSON utility and replace EscapeJsonString copies #8127

@doublemover

Description

@doublemover

Parent inventory: #8108

Objective

Create a production-only native JSON utility and replace duplicated EscapeJsonString implementations without adding a third-party JSON dependency yet.

Shared Module Specification

  • Add native/objc3c/src/io/objc3_json.h and native/objc3c/src/io/objc3_json.cpp, or an equivalent dependency-correct production location.
  • Expose objc3::io::EscapeJsonString(std::string_view) and WriteJsonString(std::ostream&, std::string_view).
  • Optionally expose tiny object/field emission helpers if doing so removes malformed-JSON risk without creating a framework.
  • Keep this production helper separate from test-only probe JSON helpers.
  • Do not add a third-party JSON dependency unless this issue records a deliberate decision and build/distribution impact.

Migration Checklist

  • Add native tests or focused acceptance coverage for JSON escaping before replacing all copies.
  • Replace each duplicate EscapeJsonString implementation.
  • Update native CMake/source lists for the new module if needed.
  • Preserve artifact schemas and emitted JSON text except for intentional validated escaping fixes.

Complete Replacement Inventory

  • EscapeJsonString - 5 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/io/objc3_diagnostics_artifacts.cpp:13
    • native/objc3c/src/io/objc3_process.cpp:334
    • native/objc3c/src/libobjc3c_frontend/frontend_anchor.cpp:183
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:317
    • native/objc3c/src/tools/objc3c_frontend_c_api_runner.cpp:185

Performance And Reliability Requirements

  • Keep helper code small, dependency-light, and fast enough for normal development feedback.
  • Add focused tests for edge cases before broad migration.
  • Preserve existing output schemas and public behavior unless an intentional bug fix is validated.
  • Keep production helpers separated from test-only helpers.
  • Do not use tmp/ as durable source-of-truth; generated temporary files are allowed only as transient command inputs.

Fast Tests

  • Run native JSON helper tests or focused C++ smoke tests.
  • Run native build.
  • Run frontend/reporting checks that consume JSON artifacts.
  • Run runtime acceptance after all replacements.
  • Run git diff --check.

End-To-End Completion Criteria

  • Only one production native JSON escaping implementation remains.
  • All five previous call sites use the shared helper.
  • No production source includes test-only probe JSON support.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions