JSON serializer uses locale-specific formatting
brendanyounger opened this issue · comments
I would like to be able to serialize an amount and read it back with the proper currency. Unfortunately, the json serializer uses locale-specific formatting, so I cannot use clojurewerkz.money.amounts/parse on the result. I would like to suggest that the amount be serialized in a locale-independent format so that it can be read again.
As an example, the following code throws org.joda.money.IllegalCurrencyException: Unknown currency '$10'
for me (with default locale of "US").
(require '[clojurewerkz.money.amounts :as ma])
(require '[clojurewerkz.money.currencies :as mc])
(require 'clojurewerkz.money.json)
(require '[cheshire.core :as json])
(->>
100.1
(ma/amount-of mc/USD)
(json/generate-string) ;; yields "$100.10" for me
(json/parse-string)
(ma/parse))
@brendanyounger I'd make existing serialisation functions locale-independent and introduce new ones that are locale-dependent. Feel free to submit a PR.