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

json_value_remove

Interface to remove serde_json::Value elements

5 releases (stable)

new 1.1.0 Jan 11, 2025
1.0.2 Dec 17, 2021
1.0.1 Dec 6, 2021
1.0.0 Sep 2, 2021

#1206 in Encoding

Download history 32/week @ 2024-09-25 12/week @ 2024-10-02 10/week @ 2024-10-09 16/week @ 2024-10-16 14/week @ 2024-10-23 26/week @ 2024-10-30 37/week @ 2024-11-06 33/week @ 2024-11-13 64/week @ 2024-11-20 43/week @ 2024-11-27 25/week @ 2024-12-04 68/week @ 2024-12-11 19/week @ 2024-12-18 1/week @ 2024-12-25 19/week @ 2025-01-01 180/week @ 2025-01-08

232 downloads per month
Used in 2 crates

MIT/Apache

10KB
87 lines

json_value_remove

Actions Status semantic-release

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

Getting Started

Installation

Add the following line to your Cargo.toml:

[dependencies]
env_applier = "x.y.z" # Replace with the latest version

Quick Start

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

Contributions are welcome!

To contribute:

  1. Fork the repository and create your branch (git checkout -b feature/my-feature).
  2. Commit your changes (git commit -m 'Add some feature').
  3. Push to the branch (git push origin feature/my-feature).
  4. Open a pull request.

For major changes, please open an issue first to discuss your proposal.

Please ensure that tests are added or updated as appropriate.


License

Licensed under either of the following, at your option:

Dependencies

~0.5–1MB
~20K SLoC