ellisk42 / ec

MIT License
487 stars 140 forks source link

Replace Yojson's `to_float` with `to_number`. #79

Closed rosekunkel closed 3 years ago

rosekunkel commented 3 years ago

Yojson.Basic.Util.to_float fails to parse numbers written without a decimal point (e.g. 0 instead of 0.0). Most json tools don't make this distinction, so this is a compatibility hazard. The to_number parser combinator can handle numbers with or without decimal points.

I ran into this issue when I tried to pretty-print input files to compression:

$ compression < input.json

worked fine, but

$ jq . input.json > input-pretty.json
$ compression < input-pretty.json

triggered an error.

rosekunkel commented 3 years ago

This pull request includes the rebuilt binaries, but if you'd prefer I can submit one that just has the changes to the .ml files and you can update the binaries yourself.

ellisk42 commented 3 years ago

thank you!