Crates.io | serde-loader |
lib.rs | serde-loader |
version | 0.2.0 |
source | src |
created_at | 2022-02-23 05:13:48.441819 |
updated_at | 2023-07-26 18:59:36.106469 |
description | Serde wrapper to load/save serializable data from relative paths |
homepage | https://github.com/jerry73204/serde-loader |
repository | https://github.com/jerry73204/serde-loader.git |
max_upload_size | |
id | 537647 |
size | 25,058 |
It provides serde wrapper to load/save serializable data from relative paths.
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()?;
MIT license. See the license file.