Skip to content

Commit

Permalink
Add JSON5 support for languages.json (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotwutingfeng committed Apr 25, 2023
1 parent ebf199b commit 8f286cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -35,6 +35,7 @@ panic = "abort"
tera = "1.15"
ignore = "0.4"
serde_json = "1"
json5 = "0.4"

[dependencies]
aho-corasick = "0.7"
Expand Down
6 changes: 4 additions & 2 deletions build.rs
@@ -1,8 +1,9 @@
extern crate ignore;
extern crate serde_json;
extern crate json5;

use std::ffi::OsStr;
use std::fs::{self, File};
use std::fs;
use std::path::Path;
use std::{cmp, env, error};

Expand All @@ -20,7 +21,8 @@ fn main() -> Result<(), Box<dyn error::Error>> {
fn generate_languages(out_dir: &OsStr) -> Result<(), Box<dyn error::Error>> {
let mut tera = tera::Tera::default();

let mut json: Value = serde_json::from_reader(File::open(&"languages.json")?)?;
let json_string: String = fs::read_to_string("languages.json")?.parse()?;
let mut json: Value = json5::from_str(&json_string)?;

for (_key, ref mut item) in json
.get_mut("languages")
Expand Down

0 comments on commit 8f286cc

Please sign in to comment.