A JavaScript-like nested object-like structure non-fallible path access interface.
This library permits the user to access values in nested structures trough the use
of get
methods that return Option<T>
. This may be used to access specific API data
without serializing it into multiple structures and making a mess.
Table of Contents 📖
Use Cases 🔍
Imagine you just accessed a song API, this API describes everything you may or may not want to know about a specific song or songs. With the help of computed indexes you can access the same path multiple times in a variable way.
Lets try it.
use Value as JsonValue;
use get;
use dyn_access;
let response = get
.await?
.
.await?;
let song_name = dyn_access!;
let song_main_artist = dyn_access!;
assert_eq!;
assert_eq!;
Obviously this isn't a real call to a real API, but the intention can be inferred from this example anyways.
Installation 📦
Add the following to your Cargo.toml
under the dependencies
section
= "1.0.0"
License 📜
This repository is dual licensed, TLDR. If your repository is open source, the library is free of use, otherwise contact licensing@flaky.es for a custom license for your use case.
For more information read the license file.