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

[Feature]: Implement convenience accessors for Value like serde_json #82

Open
1 task done
nakedible-p opened this issue May 10, 2023 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@nakedible-p
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

The Value type in serde_json has convenience accessors of Index trait and .get().

Basically how they work is that .get() will try to index the value with the given type, returning an Option<&Value> as result. Using Index trait however never fails but just returns objects that are "undefined" in JSON terms. What this means in practice is that I can do something like this:

val["networks"][0]["ip_addresses"][0].as_string()

This makes it really convenient to access free form deeply nested JSON data which would be inconvenient to map to nested structures.

In order to implement this, however, the Map variant of Value should probably be changed to something which supports fast random access, as suggested in #81.

Acceptance Criteria

No response

Suggestions for a technical implementation

No response

@nakedible-p nakedible-p added the enhancement New feature or request label May 10, 2023
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
Status: New
Development

No branches or pull requests

1 participant