1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

x/json2: fix decoder errors (#13655)

* x/json2: fix decoder errors, refactoring

* x/json2: add error-catching tests

* x/json2: add missing docs

* x/json2: fmt
This commit is contained in:
Ned
2022-03-05 19:02:43 +08:00
committed by GitHub
parent 3ef437e679
commit 0e5ae7126f
3 changed files with 133 additions and 39 deletions

View File

@@ -66,3 +66,19 @@ fn test_nested_array_object() ? {
decoded := parser.decode() ?
assert parser.n_level == 0
}
fn test_raw_decode_map_invalid() ? {
raw_decode('{"name","Bob","age":20}') or {
assert err.msg() == '[x.json2] invalid token `comma`, expecting `colon` (0:5)'
return
}
assert false
}
fn test_raw_decode_array_invalid() ? {
raw_decode('["Foo", 1,}') or {
assert err.msg() == '[x.json2] invalid token `rcbr` (0:5)'
return
}
assert false
}