message: refactor: deduplicate json parsing code
diff: use crate::io::file::create_file;
  use eyre::{Report, WrapErr};
  use serde::{Deserialize, Serialize};
  +use serde_json::{de::Read, Deserializer};
  use std::path::Path;
  -pub fn json_parse<T: for<'de> Deserialize<'de>>(s: &str) -> Result<T, Report> {
  - let mut de = serde_json::Deserializer::from_str(s);
  +/// Mitigates recursion limit error when parsing large JSONs
  +/// See https://github.com/serde-rs/json/issues/334
  +pub fn deserialize_without_recursion_limit<'de, R: Read<'de>, T: Deserialize<'de>>(
  + de: &mut Deserializer<R>,
  +) -> Result<T, Report> {
  de.disable_recursion_limit();
  - let de = serde_stacker::Deserializer::new(&mut de);
  + let de = serde_stacker::Deserializer::new(de);
  let obj = T::deserialize(de).wrap_err("When parsing JSON")?;
  Ok(obj)
  }
  +pub fn json_parse<T: for<'de> Deserialize<'de>>(s: &str) -> Result<T, Report> {
  + let mut de = Deserializer::from_str(s);
  + deserialize_without_recursion_limit(&mut de)
  +}
  +
  pub fn json_parse_bytes<T: for<'de> Deserialize<'de>>(bytes: &[u8]) -> Result<T, Report> {
  - let mut de = serde_json::Deserializer::from_slice(bytes);
  - de.disable_recursion_limit();
  - let de = serde_stacker::Deserializer::new(&mut de);
  - let obj = T::deserialize(de).wrap_err("When parsing JSON")?;
  - Ok(obj)
  + let mut de = Deserializer::from_slice(bytes);
  + deserialize_without_recursion_limit(&mut de)
  }
  pub fn json_stringify<T: Serialize>(obj: &T) -> Result<String, Report> {
  