diff --git a/src/lib.rs b/src/lib.rs index 9e55347..ec1ccf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,4 +258,24 @@ mod tests { let p = choice(literal("gnostika").to(1), one_or_more(literal(" ")).to(2)); assert_eq!(p.parse("gnostika twentynine"), Ok((1, " twentynine"))); } + + /* + * JSON BNF + * ::= + ::= | | | | | + ::= "[" [] {"," }* "]" + ::= "{" [] {"," }* "}" + ::= ":" + */ + + #[test] + fn parse_json() { + let json_null = literal("null"); + let json_true = literal("true"); + let json_false = literal("false"); + + let json_value = choice(json_null, choice(json_true, json_false)); + + assert_matches!(json_value.parse("true"), Ok(("true", ""))); + } }