json array
This commit is contained in:
parent
7a832b6ba2
commit
b7db411671
@ -101,11 +101,10 @@ mod tests {
|
||||
}
|
||||
|
||||
fn json_array() -> impl JsonParser<'static, JsonValue> {
|
||||
let val = whitespace()
|
||||
.ignore_then(json_value())
|
||||
.then_ignore(whitespace());
|
||||
let val = json_value().delimited(whitespace(), whitespace());
|
||||
|
||||
repeated(val)
|
||||
.separated_by(literal(","), false)
|
||||
.delimited(literal_char('['), literal_char(']'))
|
||||
.map(JsonValue::Array)
|
||||
}
|
||||
@ -120,9 +119,9 @@ mod tests {
|
||||
json_string().parse(r#""yolo swagg""#).unwrap(),
|
||||
(JsonValue::Str("yolo swagg".into()), "")
|
||||
);
|
||||
//TODO not correct!
|
||||
assert!(json_array().parse(r#"[ 4, 9, "ara",]"#).is_err());
|
||||
assert_eq!(
|
||||
json_array().parse(r#"[ 4 9 "foo" ]"#).unwrap(),
|
||||
json_array().parse(r#"[ 4, 9, "foo" ]"#).unwrap(),
|
||||
(
|
||||
JsonValue::Array(vec![
|
||||
JsonValue::Num(4.),
|
||||
|
Loading…
Reference in New Issue
Block a user