json: fix json.decode bug for u64 values greater than 2^31 (#11238)
parent
1570e613b5
commit
4fb570522a
|
@ -33,3 +33,14 @@ fn test_json_decode_works_with_a_dict_of_arrays() {
|
||||||
assert res.twins[1].seed == 'dfgdfgdfgd'
|
assert res.twins[1].seed == 'dfgdfgdfgd'
|
||||||
assert res.twins[1].pubkey == 'skjldskljh45sdf'
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ fn decode_u64(root &C.cJSON) u64 {
|
||||||
if isnil(root) {
|
if isnil(root) {
|
||||||
return u64(0)
|
return u64(0)
|
||||||
}
|
}
|
||||||
return u64(root.valueint)
|
return u64(root.valuedouble)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_f32(root &C.cJSON) f32 {
|
fn decode_f32(root &C.cJSON) f32 {
|
||||||
|
|
Loading…
Reference in New Issue