| Crates.io | json_value_remove |
| lib.rs | json_value_remove |
| version | 1.1.0 |
| created_at | 2021-09-02 17:47:08.902374+00 |
| updated_at | 2025-01-11 23:11:09.542981+00 |
| description | Interface to remove serde_json::Value elements. |
| homepage | |
| repository | https://github.com/jmfiaschi/json_value_remove |
| max_upload_size | |
| id | 446104 |
| size | 21,811 |
Give an interface to remove element into a json_serde::Value.
Add the following line to your Cargo.toml:
[dependencies]
env_applier = "x.y.z" # Replace with the latest version
extern crate json_value_remove;
use json_value_remove::Remove;
use serde_json::Value;
{
let mut array1: Value = serde_json::from_str(r#"{"my_table":["a","b","c"]}"#).unwrap();
assert_eq!(Some(Value::String("a".to_string())), array1.remove("/my_table/0").unwrap());
assert_eq!(r#"{"my_table":["b","c"]}"#, array1.to_string());
}
extern crate json_value_remove;
use json_value_remove::Remove;
use serde_json::Value;
{
let mut object1: Value = serde_json::from_str(r#"{"field1.0":{"field1.1":"value1.1","field1.2":"value1.2"},"field2.0":"value2.0"}"#).unwrap();
assert_eq!(Some(Value::String("value1.2".to_string())), object1.remove("/field1.0/field1.2").unwrap());
assert_eq!(r#"{"field1.0":{"field1.1":"value1.1"},"field2.0":"value2.0"}"#,object1.to_string());
}
Contributions are welcome!
To contribute:
For major changes, please open an issue first to discuss your proposal.
Please ensure that tests are added or updated as appropriate.
Licensed under either of the following, at your option: