testcase in the code:
|
func TestResolvedValIsJsonable(t *testing.T) { |
func TestResolvedValIsJsonable(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)
if err != nil {
t.Fatal(err)
}
// ...
}
but in function FromJSON
func FromJSON(r io.Reader, mhType uint64, mhLen int) (*Node, error) {
var m interface{}
// receive the preview str, it would result be like
// map { "bar" => 1 (float64) ; "baz" => 2 (float64) }
err := json.NewDecoder(r).Decode(&m)
if err != nil {
return nil, err
}
// and then, cbor would use float64 to serialize, but in fact, this value is an integer
obj, err := convertToCborIshObj(m)
if err != nil {
return nil, err
}
return WrapObject(obj, mhType, mhLen)
}
I think this is a wrong case. Please check it, thanks.
testcase in the code:
go-ipld-cbor/node_test.go
Line 337 in e249008
but in function
FromJSONI think this is a wrong case. Please check it, thanks.