Open tsaixingwei opened 4 years ago
Hi,
thanks a lot for the feedback and sorry for the delayed answer.
bowerick uses Cheshire for JSON serialization. It seem that Cheshire defaults to converting Ratios to floating point (double) values: https://github.com/dakrone/cheshire/blob/4525b23da1c17decba363202402a8a195d21705f/test/cheshire/test/core.clj#L20
Could you add a bit more context for your use case? Do you know which field is expected to be of Ratio type? Could you, e.g., convert the ratio to a string yourself and use (read-string "2/3") for reading it back?
Cheers, Ruediger
No particular use case as yet. I was just testing the library to see the extent of its functionality. As you have suggested, I could have it converted to a string and read it back into a Ratio type. But that is assuming I control both the consumer and producer.
Not a big issue though. Shall I leave this issue open until it is handled by Cheshire itself?
Clojure ratios are being converted to floating points when sent to and consumed from a JMS queue.
See this simple test code where the ratio
24/7
is converted to3.428571428571429
when consumed.