cognitect / transit-cljs

Transit for ClojureScript
http://transit-format.org
Apache License 2.0
323 stars 20 forks source link

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

Open MrEbbinghaus opened 7 years ago

MrEbbinghaus commented 7 years ago

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"]

msuess commented 6 years ago

I am having the same issue.

msuess commented 6 years ago

Added a test that exposes this behaviour. Feel free to check out my branch and run lein cljsbuild once test :)

msuess commented 6 years ago

Taking a stab at it later

p-himik commented 6 years ago

Parent issue: https://github.com/cognitect/transit-js/issues/36

puredanger commented 5 years ago

Just as an FYI, due to the difficulties of exact representation and comparison in floating point, using floats as keys in a hash table is generally considered a bad idea.