#serde-json #json #remove #value #serde #path

json_value_remove

Interface to remove serde_json::Value elements

4 releases (stable)

1.0.2 Dec 17, 2021
1.0.1 Dec 6, 2021
1.0.0 Sep 2, 2021

#2008 in Encoding

Download history 49/week @ 2024-03-11 16/week @ 2024-03-18 32/week @ 2024-03-25 96/week @ 2024-04-01 12/week @ 2024-04-08 11/week @ 2024-04-15 19/week @ 2024-04-22 23/week @ 2024-04-29 14/week @ 2024-05-06 31/week @ 2024-05-13 25/week @ 2024-05-20 15/week @ 2024-05-27 28/week @ 2024-06-03 14/week @ 2024-06-10 14/week @ 2024-06-17 18/week @ 2024-06-24

76 downloads per month
Used in 2 crates

MIT/Apache

9KB
87 lines

json_value_remove

Actions Status semantic-release

Give an interface to remove element into a json_serde::Value.

Installation

[dependencies]
json_value_remove = "1.0"

Usage

Remove in an array:

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());
}

Remove in an objects:

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());
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Apache MIT

Dependencies

~355–760KB
~17K SLoC