Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/core/jsonschema/frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,17 @@ auto SchemaFrame::to_json(
root.at("locations").assign_assume_new("dynamic", JSON::make_object());
for (const auto &location : this->locations_) {
auto entry{JSON::make_object()};
entry.assign_assume_new("parent",
sourcemeta::core::to_json(location.second.parent));
entry.assign_assume_new("parent", location.second.parent.has_value()
? JSON{sourcemeta::core::to_string(
location.second.parent.value())}
: JSON{nullptr});
entry.assign_assume_new("type",
sourcemeta::core::to_json(location.second.type));
entry.assign_assume_new("root", this->root_.empty() ? JSON{nullptr}
: JSON{this->root_});
entry.assign_assume_new("base", JSON{JSON::String{location.second.base}});
entry.assign_assume_new("pointer",
sourcemeta::core::to_json(location.second.pointer));
entry.assign_assume_new(
"pointer", JSON{sourcemeta::core::to_string(location.second.pointer)});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching these fields from token arrays to JSON Pointer strings loses the property-vs-index token typing (e.g., an object property named "0" becomes indistinguishable from array index 0 in the serialized output). Consider whether any downstream consumer expects to round-trip these values back into Pointer/WeakPointer tokens without that ambiguity.

Other locations where this applies: src/core/jsonschema/frame.cc:355, src/core/jsonschema/frame.cc:374, src/core/jsonschema/frame.cc:409.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

if (tracker.has_value()) {
entry.assign_assume_new("position",
sourcemeta::core::to_json(tracker.value().get(
Expand All @@ -371,8 +373,8 @@ auto SchemaFrame::to_json(

entry.assign_assume_new(
"relativePointer",
sourcemeta::core::to_json(
this->relative_instance_location(location.second)));
JSON{sourcemeta::core::to_string(
this->relative_instance_location(location.second))});
entry.assign_assume_new("dialect",
JSON{JSON::String{location.second.dialect}});
entry.assign_assume_new(
Expand Down Expand Up @@ -403,8 +405,8 @@ auto SchemaFrame::to_json(
auto entry{JSON::make_object()};
entry.assign_assume_new("type",
sourcemeta::core::to_json(reference.first.first));
entry.assign_assume_new("origin",
sourcemeta::core::to_json(reference.first.second));
entry.assign_assume_new(
"origin", JSON{sourcemeta::core::to_string(reference.first.second)});

if (tracker.has_value()) {
entry.assign_assume_new("position",
Expand Down
Loading
Loading