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

write-read roundtrip results in different value, when key of a map is a decimal #36

Closed
MrEbbinghaus opened this issue Jan 21, 2017 · 5 comments

Comments

@MrEbbinghaus
Copy link

MrEbbinghaus commented Jan 21, 2017

My test generator found following, wrong behavior.

(let [w (transit/writer :json) 
      r (transit/reader :json)]
      (transit/read r (transit/write w {0.5 0})))
==> {0 0}

(let [w (transit/writer :json)]
     (transit/write w {0.5 0.5}))
==> "[\"^ \",\"~i0.5\",0.5]"

Version: [com.cognitect/transit-cljs "0.8.239"]

@MrEbbinghaus MrEbbinghaus changed the title write-read roundtrip results in different value write-read roundtrip results in different value, when key of a map is a decimal Jan 21, 2017
@dchelimsky
Copy link
Contributor

dchelimsky commented Feb 10, 2017

The code you provided doesn't run as/is (the constructors to writer and reader take output and input streams in addition to the format key), and here's what I get when I run this with code that runs:

(for [t [:json :json-verbose]]
    (let [o (ByteArrayOutputStream. 2000)
          w (writer o t)]
      (write w {0.5 0})
      (.toString o)))
;; => ("[\"^ \",\"~d0.5\",0]" "{\"~d0.5\":0}")
(for [t [:json :json-verbose :msgpack]]
    (let [o (ByteArrayOutputStream. 2000)
          w (writer o t)]
      (write w {0.5 0})
      (let [i (ByteArrayInputStream. (.toByteArray o))
            r (reader i t)]
        (read r))))
;; => ({0.5 0} {0.5 0} {0.5 0})

Can you provide a repro that I can run and watch behave the way you're saying? Maybe you're using some other stream implementations?

@MrEbbinghaus
Copy link
Author

This issue is in the wrong repo.. My bad.

I use transit in clojurescript. Not clojure. Is there a way to move issues in Github?

@dchelimsky
Copy link
Contributor

Not that I know of. I think you'll just have to open a new issue in transit-cljs.

@dchelimsky
Copy link
Contributor

PS - I'd do it, but I think it's better if it comes from you so you can track it, etc.

@MrEbbinghaus
Copy link
Author

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

No branches or pull requests

2 participants