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

Float keys are encoded as ints #36

Open
cvermilion opened this issue Feb 2, 2016 · 0 comments · May be fixed by #48
Open

Float keys are encoded as ints #36

cvermilion opened this issue Feb 2, 2016 · 0 comments · May be fixed by #48

Comments

@cvermilion
Copy link

Relevant code, I think: https://github.com/cognitect/transit-js/blob/master/src/com/cognitect/transit/handlers.js#L126-L128

Encoding {1.5: 3.14} results in (verbosely) "{\"~i1.5\":3.14}", instead of "{\"~d1.5\":3.14}", so it round-trips to {1: 3.14}.

I think a fix would just involve setting the tag above based on whether the Number is an int. Naturally JavaScript has no built-in way to do this, though. I'm not much of a JS guy, but maybe Math.round(x) === x would do?

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

Successfully merging a pull request may close this issue.

1 participant