Strip `//` line comments, `/* */` block comments, and trailing commas before `}` / `]` from a JSONC string, then parse with `serde_json`. Falls back to `serde_json::json!({})` on any parse failure.
(input: &str)
| 1019 | /// before `}` / `]` from a JSONC string, then parse with `serde_json`. |
| 1020 | /// Falls back to `serde_json::json!({})` on any parse failure. |
| 1021 | pub fn parse_jsonc(input: &str) -> serde_json::Value { |
| 1022 | let stripped = strip_jsonc_comments(input); |
| 1023 | serde_json::from_str(&stripped).unwrap_or_else(|_| serde_json::json!({})) |
| 1024 | } |
| 1025 | |
| 1026 | /// Internal helper: removes JSONC comments and trailing commas. |
| 1027 | fn strip_jsonc_comments(input: &str) -> String { |