This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Description
Occasionally people ask for JSON deserialization with comments, without wanting to go all the way to JSON5 or Hjson.
This doesn't belong in serde_json which is intended strictly for JSON as described by https://json.org/.
I would like to be able to write:
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use serde::Deserialize;
use strip_json::StripComments;
fn main() -> Result<(), Box<Error>> {
let input = File::open("path/to/input.json")?;
let reader = BufReader::new(input);
let clean = StripComments::new(reader);
let mut de = serde_json::Deserializer::from_reader(clean);
println!("{:#?}", serde_json::Value::deserialize(&mut de));
Ok(())
}
Roughly the API would be:
pub struct StripComments<R>;
impl<R> StripComments<R> {
pub fn new(stream: R) -> Self;
}
impl<R: Read> Read for StripComments<R>;