json-rust
json-rust copied to clipboard
Feature Request: floating point precision
When I dump my json object, I would like to control how much precision it outputs with. This is useful because as a transit format, I don't want huge payloads because I'm printing 12 digits of my floats.
Maybe a good way to implement this is supporting decimal real numbers from some other crate.
This is also important for sending stuff to Elasticsearch, which doesn't accept floating point values without a decimal point.
This is also important for sending stuff to Elasticsearch, which doesn't accept floating point values without a decimal point.
You mean it doesn't accept 10 as 10.0? How do they handle JSON produced by JavaScript builtins?
You mean it doesn't accept 10 as 10.0?
Yes, that's what I mean. If ES decides that a field a floating point value, it won't accept things that look like integers in that field.
How do they handle JSON produced by JavaScript builtins?
I don't know
That's a rather strange design decision, JSON has no concept of floats or integers (in fact the actual number format is so loosely defined it could mean anything). I'm asking about the JS because it's impossible to produce something like {"num":10.0} with JSON.stringify().
This is the error ES gives you:
{ "type": "illegal_argument_exception", "reason": "mapper [column_name] of different type, current_type [float], merged_type [ObjectMapper]"}