You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funcTestResolvedValIsJsonable(t*testing.T) {
// we can see that the value in map "foo" for key "bar" and "baz" is **interger**data:=`{ "foo": { "bar": 1, "baz": 2 } }`n, err:=FromJSON(strings.NewReader(data), mh.SHA2_256, -1)
iferr!=nil {
t.Fatal(err)
}
// ...
}
but in function FromJSON
funcFromJSON(r io.Reader, mhTypeuint64, mhLenint) (*Node, error) {
varminterface{}
// receive the preview str, it would result be like// map { "bar" => 1 (float64) ; "baz" => 2 (float64) }err:=json.NewDecoder(r).Decode(&m)
iferr!=nil {
returnnil, err
}
// and then, cbor would use float64 to serialize, but in fact, this value is an integerobj, err:=convertToCborIshObj(m)
iferr!=nil {
returnnil, err
}
returnWrapObject(obj, mhType, mhLen)
}
I think this is a wrong case. Please check it, thanks.
The text was updated successfully, but these errors were encountered:
The wikipedia says that The format makes no distinction between integer and floating-point (https://en.wikipedia.org/wiki/JSON#Data_types_and_syntax). The Go decoder chooses to default to float64. So I think you can say that even though those look like integers, they are actually floating point numbers.
testcase in the code:
go-ipld-cbor/node_test.go
Line 337 in e249008
but in function
FromJSON
I think this is a wrong case. Please check it, thanks.
The text was updated successfully, but these errors were encountered: