fix: switched from serde_json5 to json5

This commit is contained in:
zonyitoo
2025-12-07 21:38:23 +08:00
parent ea5e435b85
commit 04b3ad8504
6 changed files with 28 additions and 83 deletions

95
Cargo.lock generated
View File

@@ -140,7 +140,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -151,7 +151,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -820,7 +820,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -927,7 +927,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -1764,6 +1764,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json5"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfcd7c9a7e6d6270614c3c7ccec2ec6fb0bf7f6da3384042e80e737cde1f941"
dependencies = [
"serde",
"ucd-trie",
]
[[package]]
name = "kqueue"
version = "1.1.1"
@@ -2106,7 +2116,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -2259,49 +2269,6 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "pest"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4"
dependencies = [
"memchr",
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.110",
]
[[package]]
name = "pest_meta"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a"
dependencies = [
"pest",
"sha2",
]
[[package]]
name = "pin-project"
version = "1.1.10"
@@ -2780,7 +2747,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -2993,17 +2960,6 @@ dependencies = [
"serde_core",
]
[[package]]
name = "serde_json5"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d34d03f54462862f2a42918391c9526337f53171eaa4d8894562be7f252edd3"
dependencies = [
"pest",
"pest_derive",
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -3040,17 +2996,6 @@ dependencies = [
"digest",
]
[[package]]
name = "sha2"
version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "shadowsocks"
version = "1.23.2"
@@ -3133,6 +3078,7 @@ dependencies = [
"futures",
"ipnet",
"jemallocator",
"json5",
"libc",
"log",
"log4rs",
@@ -3143,7 +3089,6 @@ dependencies = [
"rpassword",
"rpmalloc",
"serde",
"serde_json5",
"shadowsocks-service",
"snmalloc-rs",
"sysexits",
@@ -3182,6 +3127,7 @@ dependencies = [
"idna",
"ipnet",
"iprange",
"json5",
"libc",
"log",
"lru_time_cache",
@@ -3195,7 +3141,6 @@ dependencies = [
"rustls-native-certs",
"serde",
"serde_json",
"serde_json5",
"shadowsocks",
"smoltcp",
"socket2 0.6.1",
@@ -3487,7 +3432,7 @@ dependencies = [
"getrandom 0.3.4",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -4115,7 +4060,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.61.2",
]
[[package]]

View File

@@ -219,7 +219,7 @@ tracing-appender = { version = "0.2.3", optional = true, default-features = fals
time = { version = "0.3", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json5 = "0.2"
json5 = "1.2"
thiserror = "2.0"
base64 = "0.22"

View File

@@ -195,7 +195,7 @@ smoltcp = { version = "0.12", optional = true, default-features = false, feature
] }
serde = { version = "1.0", features = ["derive"] }
serde_json5 = "0.2"
json5 = "1.2"
serde_json = "1.0"
bson = { version = "3.0.0", features = ["serde"], optional = true }

View File

@@ -1457,7 +1457,7 @@ macro_rules! impl_from {
}
impl_from!(::std::io::Error, ErrorKind::IoError, "error while reading file");
impl_from!(serde_json5::Error, ErrorKind::JsonParsingError, "json parse error");
impl_from!(json5::Error, ErrorKind::JsonParsingError, "json parse error");
impl_from!(serde_json::Error, ErrorKind::JsonParsingError, "json parse error");
impl Debug for Error {
@@ -2565,7 +2565,7 @@ impl Config {
/// Load Config from a `str`
pub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self, Error> {
let c = serde_json5::from_str::<SSConfig>(s)?;
let c = json5::from_str::<SSConfig>(s)?;
Self::load_from_ssconfig(c, config_type)
}
@@ -3185,7 +3185,7 @@ impl fmt::Display for Config {
});
}
write!(f, "{}", serde_json5::to_string(&jconf).unwrap())
write!(f, "{}", json5::to_string(&jconf).unwrap())
}
}

View File

@@ -66,7 +66,7 @@ impl Socks5AuthConfig {
let mut content = String::new();
reader.read_to_string(&mut content)?;
let jconf: SSSocks5AuthConfig = match serde_json5::from_str(&content) {
let jconf: SSSocks5AuthConfig = match json5::from_str(&content) {
Ok(c) => c,
Err(err) => return Err(io::Error::other(err)),
};

View File

@@ -88,7 +88,7 @@ pub enum ConfigError {
IoError(#[from] io::Error),
/// JSON parsing error
#[error("{0}")]
JsonError(#[from] serde_json5::Error),
JsonError(#[from] json5::Error),
/// Invalid value
#[error("Invalid value: {0}")]
InvalidValue(String),
@@ -120,7 +120,7 @@ impl Config {
/// Load `Config` from string
pub fn load_from_str(s: &str) -> Result<Self, ConfigError> {
serde_json5::from_str(s).map_err(ConfigError::from)
json5::from_str(s).map_err(ConfigError::from)
}
/// Set by command line options