mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
json: allow i32
decoding and encoding (#21162)
This commit is contained in:
parent
c086bee5be
commit
656009dc62
2 changed files with 26 additions and 4 deletions
16
vlib/json/json_i32_test.v
Normal file
16
vlib/json/json_i32_test.v
Normal file
|
@ -0,0 +1,16 @@
|
|||
import json
|
||||
|
||||
pub struct StructB {
|
||||
kind string
|
||||
value i32
|
||||
}
|
||||
|
||||
fn test_json_i32() {
|
||||
struct_b := json.decode(StructB, '{"kind": "Int32", "value": 100}')!
|
||||
assert struct_b == StructB{
|
||||
kind: 'Int32'
|
||||
value: 100
|
||||
}
|
||||
|
||||
assert json.encode(struct_b) == '{"kind":"Int32","value":100}'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue