Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbor: compatible with encoder/json #86

Closed
jbenet opened this issue Jul 17, 2015 · 3 comments
Closed

cbor: compatible with encoder/json #86

jbenet opened this issue Jul 17, 2015 · 3 comments

Comments

@jbenet
Copy link

jbenet commented Jul 17, 2015

encoding/json uses map[string]interface{} which is incompatible with map[interface{}]interface{}. parsing cbor and encoding to json is not happy:

json: unsupported type: map[interface {}]interface {}
@jbenet
Copy link
Author

jbenet commented Jul 17, 2015

I made a nice cli tool to check this:

cat a_bunch_of.json | json2cbor j2c >a_bunch_of.cbor
cat a_bunch_of.cbor | json2cbor c2j >a_bunch_of.json

Can use with https://github.com/jbenet/node-random-json-stream to check things. Setup:

go get github.com/jbenet/go-json2cbor/json2cbor
npm install -g random-json-stream

Test codec with:

random-json -o | json2cbor j2c | json2cbor c2j

Test JSON->CBOR->JSON roundtripping with:

random-json -o -c 10 | tee a.json | json2cbor j2c | json2cbor c2j >b.json && diff a.json b.json

@jbenet
Copy link
Author

jbenet commented Jul 17, 2015

I should note that the codec seems to fail when i try to convert 10+ json->cbor->json items. with:

unexpected EOF

it could be the tool, but i believe it's something about the codec.

@jbenet
Copy link
Author

jbenet commented Jul 17, 2015

nevermind. I made a mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants