tree: 021dc81c5b4659be85ade612fd201b8c9bfdc379 [path history] [tgz]
  1. .github/
  2. benches/
  3. examples/
  4. src/
  5. tests/
  6. .android-checksum.json
  7. .cargo-checksum.json
  8. .cargo_vcs_info.json
  9. .rustfmt.toml
  10. Android.bp
  11. Cargo.lock
  12. Cargo.toml
  13. Cargo.toml.orig
  14. cargo_embargo.json
  15. CHANGELOG.md
  16. LICENSE
  17. METADATA
  18. MODULE_LICENSE_MIT
  19. README.md
  20. rust-toolchain.toml
crates/json-strip-comments/README.md

JSON Strip Comments

Crates.io Docs.rs

A fork of a fork for stripping JSON comments and trailing commas in place:

Example

use serde_json::Value;

fn main() {
    let mut data = String::from(
        r#"
     {
         "name": /* full */ "John Doe",
         "age": 43, # hash line comment
         "phones": [
             "+44 1234567", // work phone
             "+44 2345678", // home phone
         ], /** comment **/
     }"#,
    );

    json_strip_comments::strip(&mut data).unwrap();
    let value: Value = serde_json::from_str(&data).unwrap();

    println!("{value}");
}