Skip to content

Commit a8d200a

Browse files
authored
decoder2: improve enum decoding; fix handling of required fields at the end of a json string (#25289)
1 parent 56f20d1 commit a8d200a

File tree

4 files changed

+258
-121
lines changed

4 files changed

+258
-121
lines changed

vlib/x/json2/decoder2/attributes_test.v

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ struct StruWithRequiredAttribute {
3838
b int
3939
}
4040

41+
struct Foo {
42+
a int @[required]
43+
}
44+
45+
fn test_last_field_requiered() {
46+
assert json.decode[Foo]('{"a":0}')! == Foo{
47+
a: 0
48+
}
49+
}
50+
4151
fn test_skip_and_rename_attributes() {
4252
assert json.decode[StruWithJsonAttribute]('{"name": "hola1", "a": 2, "b": 3}')! == StruWithJsonAttribute{
4353
a: 2

0 commit comments

Comments
 (0)