json: allow i32 decoding and encoding (#21162)

This commit is contained in:
Swastik Baranwal 2024-04-02 07:54:36 +05:30 committed by GitHub
parent c086bee5be
commit 656009dc62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 4 deletions

16
vlib/json/json_i32_test.v Normal file
View 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}'
}