Crates.io | json-strip-comments |
lib.rs | json-strip-comments |
version | 3.0.1 |
created_at | 2024-01-19 08:11:31.033241+00 |
updated_at | 2025-09-15 10:25:52.922009+00 |
description | Strip comments from JSON |
homepage | |
repository | https://github.com/oxc-project/json-strip-comments |
max_upload_size | |
id | 1105060 |
size | 55,178 |
A fork of a fork for stripping JSON comments and trailing commas in place:
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}");
}