feat(value): add ergonomic type checking and accessor methods to JsonValue - #262
Open
Aditya-9-6 wants to merge 3 commits into
Open
feat(value): add ergonomic type checking and accessor methods to JsonValue#262Aditya-9-6 wants to merge 3 commits into
Aditya-9-6 wants to merge 3 commits into
Conversation
Signed-off-by: Aditya Dahale <aditya.dahale@example.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will degrade performance by 15.52%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | massive_ints_array_jiter_iter |
564.1 µs | 685 µs | -17.65% |
| ❌ | python_parse_massive_ints_array |
1.1 ms | 1.4 ms | -16.66% |
| ❌ | massive_ints_array_jiter_value |
743 µs | 845.6 µs | -12.14% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Aditya-9-6:main (3e307d2) with main (785cf75)
added 2 commits
August 16, 2026 16:07
…ive test coverage for JsonValue accessors Signed-off-by: Aditya Dahale <aditya.dahale@example.com>
Signed-off-by: Aditya Dahale <aditya.dahale@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, working with
JsonValuein pure Rust code requires matching onJsonValuevariants for every access. Adding standard accessor and type checking methods (similar toserde_json::Value) improves developer ergonomics significantly when querying or inspecting parsed JSON data.Solution
Added the following accessor methods to
JsonValue<'j>:is_null(),is_boolean(),is_number(),is_int(),is_float(),is_string(),is_array(),is_object()as_bool(),as_i64(),as_f64(),as_str(),as_array(),as_object()get(key: &str) -> Option<&JsonValue<'j>>