Skip to main content

parse_json_response

Function parse_json_response 

Source
pub fn parse_json_response(text: &str) -> Option<Value>
Expand description

Strip markdown code fences (```json … ```) and parse the inner JSON.

If the text is plain JSON (no fences), it is parsed directly. Returns None when the text is not valid JSON after stripping.

§Example

let text = r#"```json\n{"title": "Plan"}\n```"#;
let value = parse_json_response(text).unwrap();
assert_eq!(value["title"], "Plan");