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

json: fix json.decode bug for u64 values greater than 2^31 (#11238)

This commit is contained in:
Hualin Song 2021-08-20 14:14:55 +08:00 committed by GitHub
parent 1570e613b5
commit 4fb570522a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -33,3 +33,14 @@ fn test_json_decode_works_with_a_dict_of_arrays() {
assert res.twins[1].seed == 'dfgdfgdfgd'
assert res.twins[1].pubkey == 'skjldskljh45sdf'
}
struct Mount {
size u64
}
fn test_decode_u64() ? {
data := '{"size": 10737418240}'
m := json.decode(Mount, data) ?
assert m.size == 10737418240
println(m)
}

View File

@ -96,7 +96,7 @@ fn decode_u64(root &C.cJSON) u64 {
if isnil(root) {
return u64(0)
}
return u64(root.valueint)
return u64(root.valuedouble)
}
fn decode_f32(root &C.cJSON) f32 {