Importing numbers with json encoding
- Dominant language
- Go
- Stars
- 17.1k
- Forks
- 3.2k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 11
Description
#### Version information:
go-ipfs version: 0.7.0
Repo version: 10
System version: amd64/darwin
Golang version: go1.14.4
#### Description:
Importing `1` with json encoding results in cbor for `1.0`:
```console
$ echo 1 | ipfs dag put --input-enc json
bafyreihtx752fmf3zafbys5dtr4jxohb53yi3qtzfzf6wd5274jwtn5agu
$ ipfs block get bafyreihtx752fmf3zafbys5dtr4jxohb53yi3qtzfzf6wd5274jwtn5agu | xxd
00000000: fb3f f000 0000 0000 00 .?.......
```
Plugging that into cbor.me shows '1.0': http://cbor.me/?bytes=fb3ff0000000000000
js-IPFS does it differently:
```console
$ echo 1 | jsipfs dag put --input-enc json
bafyreicl6ujc6ncfktctxxroxognfn7d2fqavvrryoc2lv6m4i6hpbkfti
$ jsipfs block get bafyreicl6ujc6ncfktctxxroxognfn7d2fqavvrryoc2lv6m4i6hpbkfti | xxd
00000000: 01 .
```
This shows `1`: http://cbor.me/?bytes=01
They seem to agree on non-whole numbers though:
```
$ echo 10.1 | ipfs dag put --input-enc json
bafyreif6mmzorbl3afjsxe56edgibwbmhaje5k744nxioruox4kixlkr4u
$ echo 10.1 | jsipfs dag put --input-enc json
bafyreif6mmzorbl3afjsxe56edgibwbmhaje5k744nxioruox4kixlkr4u
```
Contributor guide
Assessment
This issue has not been assessed yet.