Skip to main content

extract

Function extract 

Source
pub fn extract(input: &str) -> Option<&str>
Expand description

Returns the first JSON value found in input, trimmed of surrounding prose.

A fenced markdown block wins over loose text; inside loose text the first balanced {...} or [...] wins.

let text = "Sure! Here is the data:\n```json\n{\"ok\": true}\n```\nEnjoy.";
assert_eq!(jsonfix::extract(text), Some("{\"ok\": true}"));