MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / load_json_file

Function load_json_file

src/agents/mod.rs:445–452  ·  view source on GitHub ↗

Load a JSON file, returning an empty object on missing/invalid. Use this for **read-only** paths (healthcheck, `has_tracedecay`, etc.). For install/edit paths, use [`load_json_file_strict`] instead.

(path: &Path)

Source from the content-addressed store, hash-verified

443/// Use this for **read-only** paths (healthcheck, `has_tracedecay`, etc.).
444/// For install/edit paths, use [`load_json_file_strict`] instead.
445pub fn load_json_file(path: &Path) -> serde_json::Value {
446 if path.exists() {
447 let contents = std::fs::read_to_string(path).unwrap_or_default();
448 serde_json::from_str(&contents).unwrap_or_else(|_| serde_json::json!({}))
449 } else {
450 serde_json::json!({})
451 }
452}
453
454/// Load a JSON file for **editing**. Unlike [`load_json_file`], this returns
455/// an error if the file exists but cannot be parsed, preventing silent data

Callers 15

has_tracedecayMethod · 0.85
has_tracedecayMethod · 0.85
doctor_check_settingsFunction · 0.85
has_tracedecayMethod · 0.85
doctor_check_settingsFunction · 0.85
doctor_check_cli_pluginFunction · 0.85
doctor_check_plugin_dirFunction · 0.85
doctor_check_hooksFunction · 0.85

Calls 1

existsMethod · 0.80