pub fn safe_parse(text: &str) -> SafeOutcomeExpand description
Parse JSON text and fold every outcome into a SafeOutcome.
Runs with both actions at Action::Error and safe on. A clean parse
returns SafeOutcome::Value. A forbidden key returns
SafeOutcome::Violation. Malformed JSON returns SafeOutcome::Malformed.
This never returns an error type.
ยงExamples
use secure_json_parse::{safe_parse, SafeOutcome};
match safe_parse(r#"{"a": 1}"#) {
SafeOutcome::Value(v) => assert_eq!(v, serde_json::json!({"a": 1})),
_ => panic!("expected a value"),
}