cognitect / transit-cljs

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

Decimal as map key incorrectly serializes to int #57

Closed bbss closed 2 years ago

bbss commented 3 years ago
(ns example
  (:require [cognitect.transit :as t]))

(defn roundtrip [x]
  (let [w (t/writer :json)
        r (t/reader :json)]
    (js/console.log (t/write w x)) ;; ["^ ","~i1.1",1.1]
    (t/read r (t/write w x))))

(defn failing-decimal-key []
  (let [data  {1.1 1.1}
        data' (roundtrip data) ;;=> {1 1.1}
        ]
    (js/console.log data data')
    (assert (= data data'))))

(defn init [] (failing-decimal-key))

I think this is a bug in transit-js, transit-clj writing will tag the key with ~d

bbss commented 2 years ago

duplicate of https://github.com/cognitect/transit-js/issues/36