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

Function parse_jsonc

src/agents/mod.rs:1021–1024  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1019/// before `}` / `]` from a JSONC string, then parse with `serde_json`.
1020/// Falls back to `serde_json::json!({})` on any parse failure.
1021pub 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.
1027fn strip_jsonc_comments(input: &str) -> String {

Calls 1

strip_jsonc_commentsFunction · 0.85