Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonReader method for undoing seek_to #53

Closed
Marcono1234 opened this issue Feb 27, 2024 · 0 comments
Closed

Add JsonReader method for undoing seek_to #53

Marcono1234 opened this issue Feb 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Marcono1234
Copy link
Owner

Problem solved by the enhancement

After using JsonReader::seek_to and consuming a value it is currently not easily possible to get back to the original nesting level again to continue reading there (except for the top-level with JsonReader::skip_to_top_level).

Enhancement description

Add a method for 'undoing' a seek_to by consuming all remaining array items and object members and closing arrays and objects in reverse order.

The implementation for this was already added for #48 & #49 but is currently internal, see src/reader/simple.rs function undo_seek. It would make sense to move it to JsonReader, but add additional validation there that it properly detects an incorrect state, even if the path is empty (if possible?).

Maybe need a better name for this than 'undo' because it might give the incorrect impression that afterwards the reader is at the exact same position it was before and can read the same value again.

Alternatives / workarounds

Use the Simple API instead of JsonReader? (probably not always possible)

@Marcono1234 Marcono1234 added the enhancement New feature or request label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant