4 releases
0.1.3 | Oct 21, 2019 |
---|---|
0.1.2 | Oct 16, 2019 |
0.1.1 | Oct 14, 2019 |
0.1.0 | Oct 12, 2019 |
#130 in #save
Used in 2 crates
5KB
forge_util introduction
Intro
forge_util
implement by Rust
. Provide apis to save a Json in local.
Help user
APIs
/// save Json to local
/// value: Json to save.
/// path: local path where to save, `empty` will save to default path `./settings.json`
config_save_settings(value: &Value, path: &str) -> Result<()>
/// get Json from local
/// path: Json file local path, `empty` will use default path `./settings.json`
config_get_settings(path: &str) -> Result<Value>
Example
let people = serde_json::json!({"name":"alice","age":18,"sex":true});
let path = "./config_test.json";
config_save_settings(&people, path)?;
assert_eq!(people, config_get_settings(path)?);
Example above will create a Json file ./config_test.json
:
./config_test.json
:
{
"age": 18,
"name": "alice",
"sex": true
}
Dependencies
~0.8–1.7MB
~37K SLoC