6 releases
0.2.0 | Jul 26, 2023 |
---|---|
0.1.4 | Apr 5, 2022 |
0.1.3 | Feb 23, 2022 |
#19 in #relative-path
30 downloads per month
23KB
753 lines
serde-loader
It provides serde wrapper to load/save serializable data from relative paths.
Example
It allows to write file paths instead of data during serialization. Suppose we have the following JSON files to be loaded.
main.json
{
"sub": "sub/sub.json"
}
sub/sub.json
{
"sub": "sub/sub.json"
}
sub/sub/sub_of_sub.json
{
"sub": "sub/sub_of_sub.json"
}
This crate provides the JsonPath
wrapper load JSON files recursively.
use serde_loader::JsonPath;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct Main {
pub sub: JsonPath<Sub>
}
#[derive(Serialize, Deserialize)]
struct Sub {
pub sub: JsonPath<SubOfSub>
}
#[derive(Serialize, Deserialize)]
struct SubOfSub {
pub name: String,
pub value: String,
}
let config: JsonPath<Main> = JsonPath::open("tests/config-example/main.json")?;
config.save()?;
License
MIT license. See the license file.
Dependencies
~0.4–1.9MB
~40K SLoC