Skip to content

Extend value to arrays when using JSON pointers#5223

Merged
nlohmann merged 3 commits into
developfrom
fix/3755-value-json_pointer-array
Jul 2, 2026
Merged

Extend value to arrays when using JSON pointers#5223
nlohmann merged 3 commits into
developfrom
fix/3755-value-json_pointer-array

Conversation

@nlohmann

@nlohmann nlohmann commented Jul 1, 2026

Copy link
Copy Markdown
Owner

As discovered here, value(json_pointer) throws an exception, when accessing an array. This deviates from the documented behavior:

try {
   return at(ptr);
} catch(out_of_range) {
   return default_value;
}

Allow value(json_pointer) to work with arrays, update documentation, and update unit tests.

Replaces stale #3759

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@github-actions github-actions Bot added L and removed M labels Jul 1, 2026
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
@nlohmann nlohmann added the review needed It would be great if someone could review the proposed changes. label Jul 1, 2026
@nlohmann nlohmann marked this pull request as ready for review July 1, 2026 13:24
@nlohmann nlohmann added this to the Release 3.12.1 milestone Jul 1, 2026
@nlohmann nlohmann removed the review needed It would be great if someone could review the proposed changes. label Jul 1, 2026
@nlohmann nlohmann merged commit ca49ab6 into develop Jul 2, 2026
142 checks passed
@nlohmann nlohmann deleted the fix/3755-value-json_pointer-array branch July 2, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants