use crate::{
parsers::{FileParserBuilder, Load},
AnyResult, Case, Value,
};
use std::io::Read;
#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Failed parse JSON")]
ParseJson(#[source] serde_json::Error),
}
pub type ParserBuilder = FileParserBuilder<LoadJson>;
#[derive(Clone, Default)]
pub struct LoadJson;
impl Case for LoadJson {}
impl Load for LoadJson {
#[inline]
fn load(&mut self, reader: impl Read) -> AnyResult<Value> {
Ok(serde_json::from_reader(reader).map_err(Error::ParseJson)?)
}
}