mirror of
https://github.com/a2x/cs2-dumper.git
synced 2026-04-17 19:49:58 +08:00
Modify JSON file generation for easier parsing
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write;
|
||||
|
||||
use heck::{AsPascalCase, AsSnakeCase};
|
||||
@@ -73,6 +74,22 @@ impl CodeGen for InterfaceMap {
|
||||
})
|
||||
}
|
||||
|
||||
fn to_json(&self, _results: &Results, _indent_size: usize) -> Result<String> {
|
||||
let content: BTreeMap<_, _> = self
|
||||
.iter()
|
||||
.map(|(module_name, ifaces)| {
|
||||
let ifaces: BTreeMap<_, _> = ifaces
|
||||
.iter()
|
||||
.map(|iface| (&iface.name, iface.value))
|
||||
.collect();
|
||||
|
||||
(module_name, ifaces)
|
||||
})
|
||||
.collect();
|
||||
|
||||
serde_json::to_string_pretty(&content).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn to_rs(&self, results: &Results, indent_size: usize) -> Result<String> {
|
||||
self.write_content(results, indent_size, |fmt| {
|
||||
writeln!(fmt, "#![allow(non_upper_case_globals, unused)]\n")?;
|
||||
|
||||
Reference in New Issue
Block a user