https://github.com/flakysl/dyn_path
A JavaScript-like nested object-like structure non-fallible path access interface. Access your data without serializing it just like you do in your JavaScript projects.
https://github.com/flakysl/dyn_path
dynamism javascript json serialization serializing
Last synced: 4 months ago
JSON representation
A JavaScript-like nested object-like structure non-fallible path access interface. Access your data without serializing it just like you do in your JavaScript projects.
- Host: GitHub
- URL: https://github.com/flakysl/dyn_path
- Owner: FlakySL
- License: other
- Created: 2025-06-30T23:51:03.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-09-15T06:59:28.000Z (5 months ago)
- Last Synced: 2025-10-11T01:13:25.547Z (4 months ago)
- Topics: dynamism, javascript, json, serialization, serializing
- Language: Rust
- Homepage: https://crates.io/crates/dyn_path
- Size: 71.3 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Governance: GOVERNANCE.md
Awesome Lists containing this project
README

[](https://crates.io/crates/dyn_path)
[](./LICENSE)
[](https://docs.rs/dyn_path)
[](https://crates.io/crates/dyn_path)
[](https://app.codecov.io/gh/FlakySL/dyn_path)

[](https://discord.gg/AJWFyps23a)
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`. This may be used to access specific API data
without serializing it into multiple structures and making a mess.
## Table of Contents 📖
- [Use Cases](#use-cases-)
- [Installation](#installation-)
- [No STD](#no-std-)
- [Licensing](#license-)
## 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.
```rust
use serde_json::Value as JsonValue;
use reqwest::get;
use dyn_path::dyn_access;
let response = get("https://api.platform-ending-with-fy.com/v1/tracks/5cbpoIu3YjoOwbBDGUEp3P")
.await?
.json::()
.await?;
let song_name = dyn_access!(response.album.name);
let song_main_artist = dyn_access!(response.album.artists[0].name);
assert_eq!(song_name, "Car Radio");
assert_eq!(song_main_artist, "Twenty One Pilots");
```
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
```toml
dyn_path = "1.0.7"
```
## No std 💡
This crate supports `no_std`, meaning you can use it in your project without
depending on specific system I/O or anything else.
The crate has a default feature enabled which is `std`, with this feature
the crate doesn't really use `std` but it pre-includes `alloc` which
permits the use of the `dyn_path` macro, which uses `String` to describe
a path.
You can also disable the default features and the crate will annotate `no_std`.
Then use the `alloc` feature if you want to have the `dyn_path` macro enabled.
## License 📜
This repository is dual licensed, TLDR. If your repository is open source, the library
is free of use, otherwise contact [licensing@flaky.es](mailto:licensing@flaky.es) for a custom license for your
use case.
For more information read the [license](./LICENSE) file.