Read a file and parse it as JSONC. Falls back to `json!({})` if the file is missing, unreadable, or unparseable. Use this for **read-only** paths. For install/edit paths, use [`load_jsonc_file_strict`] instead.
(path: &Path)
| 1120 | /// Use this for **read-only** paths. For install/edit paths, use |
| 1121 | /// [`load_jsonc_file_strict`] instead. |
| 1122 | pub fn load_jsonc_file(path: &Path) -> serde_json::Value { |
| 1123 | let Ok(contents) = std::fs::read_to_string(path) else { |
| 1124 | return serde_json::json!({}); |
| 1125 | }; |
| 1126 | parse_jsonc(&contents) |
| 1127 | } |
| 1128 | |
| 1129 | /// Load a JSONC file for **editing**. Unlike [`load_jsonc_file`], this returns |
| 1130 | /// an error if the file exists but cannot be parsed after comment stripping, |