mirror of
https://github.com/nlohmann/json.git
synced 2026-11-03 11:25:33 +00:00
json_view: a value that is not found has no bytes in its exception context
Keeping the byte range of the root value (#5990) dropped the found flag of value_path(), but a root has no tokens and is found, while a view of a value that was removed from the document is not found. Without the flag, the removed value got the bytes of its stale node, and "json_view exceptions name the path and the bytes of the value" failed on the macOS jobs with JSON_DIAGNOSTICS and JSON_DIAGNOSTIC_POSITIONS. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+12
-4
No files matched your search
Generated
+6
-2
@@ -5080,8 +5080,12 @@ std::string diagnostics(const error_site site)
|
||||
std::string context;
|
||||
#if JSON_DIAGNOSTICS
|
||||
std::vector<std::string> tokens;
|
||||
// a value that is not found leaves no tokens, like the root
|
||||
static_cast<void>(edited ? value_path<true>(d, site.value(), tokens) : value_path<false>(d, site.value(), tokens));
|
||||
const bool found = edited ? value_path<true>(d, site.value(), tokens) : value_path<false>(d, site.value(), tokens);
|
||||
if (!found)
|
||||
{
|
||||
// a value that is not found has no path, and with it no bytes
|
||||
return context;
|
||||
}
|
||||
if (!tokens.empty())
|
||||
{
|
||||
// the root value has no path, but still has a byte range
|
||||
|
||||
Reference in new issue
Block a user