aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2022-11-13 15:29:29 +0100
committerGitHub <noreply@github.com>2022-11-13 15:29:29 +0100
commitfa25001d7f2a1962de8990f077f7f1601679a292 (patch)
tree95116620a6bff140826154a2bd39a965f1955d03 /src-tauri
parent8393a08f4cb937805d41bb9a0f7901fb5221746e (diff)
downloadFlightCore-fa25001d7f2a1962de8990f077f7f1601679a292.tar.gz
FlightCore-fa25001d7f2a1962de8990f077f7f1601679a292.zip
feat: Add JSON5 support, allows comments in JSON (#50)
Some mods have comments in their JSON. Northstar handles it fine, so we should too.
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/Cargo.lock12
-rw-r--r--src-tauri/Cargo.toml2
-rw-r--r--src-tauri/src/mod_management/mod.rs4
3 files changed, 17 insertions, 1 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index ec50c51c..b6f27065 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -79,6 +79,7 @@ name = "app"
version = "0.3.1"
dependencies = [
"anyhow",
+ "json5",
"libthermite",
"powershell_script",
"regex",
@@ -1581,6 +1582,17 @@ dependencies = [
]
[[package]]
+name = "json5"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
+dependencies = [
+ "pest",
+ "pest_derive",
+ "serde",
+]
+
+[[package]]
name = "keyvalues-parser"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 4e0d2cba..ab2de8bf 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -38,6 +38,8 @@ sysinfo = "0.26.2"
reqwest = { version = "0.11", features = ["blocking"] }
# Persistent store for settings
tauri-plugin-store = { git = "https://github.com/tauri-apps/tauri-plugin-store", branch = "dev" }
+# JSON5 parsing support (allows comments in JSON)
+json5 = "0.4.1"
[features]
# by default Tauri runs in production mode
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index e3034903..ecfd3835 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -7,6 +7,8 @@ use std::path::PathBuf;
use app::GameInstall;
use app::get_enabled_mods;
+use json5;
+
/// Set the status of a passed mod to enabled/disabled
pub fn set_mod_enabled_status(
game_install: GameInstall,
@@ -42,7 +44,7 @@ pub fn set_mod_enabled_status(
fn parse_mod_json_for_mod_name(mod_json_path: String) -> Result<String, anyhow::Error> {
// Read file into string and parse it
let data = std::fs::read_to_string(mod_json_path)?;
- let parsed_json: serde_json::Value = serde_json::from_str(&data)?;
+ let parsed_json: serde_json::Value = json5::from_str(&data)?;
// Extract mod name
let mod_name = match parsed_json.get("Name").and_then(|value| value.as_str()) {