Repository navigation
Add pretty printing for vajson serializer - #636
Conversation
|
Documentation preview for this pull request is available at: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The newly added tests use legacy requirement metadata that must be replaced with current component-requirement links.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds optional pretty printing to the vaJSON serializer while preserving backend-specific behavior.
Changes:
- Propagates a
pretty_printoption throughJsonWriterand serializer backends. - Adds structural whitespace handling for nested JSON containers.
- Adds compact and pretty-print serialization tests.
| File | Description |
|---|---|
score/json/json_writer.h |
Exposes the formatting option. |
score/json/json_writer.cpp |
Propagates formatting to backends. |
score/json/json_writer_test.cpp |
Updates shared expectations and tests compact output. |
score/json/internal/writer/writer_backend.h |
Extends backend interfaces. |
score/json/internal/writer/vajson/writer/serializers/util/formatting_writer.h |
Implements whitespace and indentation. |
score/json/internal/writer/vajson/writer/serializers/structures/serializer.h |
Uses the formatting writer type. |
score/json/internal/writer/vajson/writer/serializers/structures/key_serializer.h |
Formats object members. |
score/json/internal/writer/vajson/writer/serializers/structures/generic_value_serializer.h |
Formats values and arrays. |
score/json/internal/writer/vajson/writer/serializers/structures/generic_value_serializer_impl.h |
Formats objects. |
score/json/internal/writer/vajson/vajson_serialize.h |
Extends vaJSON serialization APIs. |
score/json/internal/writer/vajson/vajson_serialize.cpp |
Configures formatting per serialization. |
score/json/internal/writer/vajson/vajson_serialize_test.cpp |
Covers pretty and compact output. |
score/json/internal/writer/vajson/vajson_backend.cpp |
Forwards formatting through vaJSON. |
score/json/internal/writer/json_serialize/json_serialize_backend.cpp |
Accepts but ignores formatting configuration. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mihajlo-k
left a comment
There was a problem hiding this comment.
Nice implementation!
I have a couple of comments that could be addressed in the follow-up, thus non-blocking.
| #if defined(WRITER_VAJSON) | ||
| static constexpr auto expected = R"([1234,"string",{"key":"value"}])"; |
There was a problem hiding this comment.
here the test coverage for compact formatting is lost. maybe now we can parametrize the tests here to cover both formatting.
| const score::filesystem::AtomicUpdateOwnershipFlags ownership) noexcept | ||
| : IJsonWriter{}, file_sync_mode_{file_sync_mode}, atomic_ownership_{ownership} | ||
| const score::filesystem::AtomicUpdateOwnershipFlags ownership, | ||
| const bool pretty_print) noexcept |
There was a problem hiding this comment.
If someone encounters a call like this:
JsonWriter writer{sync_mode, ownership, true};,
it might not be clear to them what true means, and they might need to look into the constructor itself to understand.
To make the API more understandable we could use scoped enum (e.g. PrettyPrint::kDisabled and PrettyPrint::kEnabled or Formatting::kCompact and Formatting::kPrettyPrint).
|
It is worth noting that there is a slight deviation in formatting between json serializer and vajson serializer with pretty printing. Namely json serializer serializes the empty list/object in a way that it splits opening and closing brackets in two separate lines ( |
The |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: JuriSchroeder <84773803+JuriSchroeder@users.noreply.github.com>
…eder/baselibs into vajson-serializer-pretty-print

No description provided.