Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON.

Abierto
#817 3 comentarios 1 reacción 1 asignado Ver en GitHub

@headius ya está trabajando en esto.

Desde el 25/8/2025.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

jruby

In Ruby 3.4, when converting a Float value to JSON using .to_json, the output notation is more or less preserved. Namely, if your value is in scientific notation, the output will be in scientific notation. If it's decimal, it will remain decimal, though there does appear to be a precision limit where it will truncate additional decimals.

In jRuby 10.0.0.1, Float values above a certain size will always be converted to scientific notation in the output. The precision doesn't appear to be the culprit, it seems to be the number of digits to the LEFT of the decimal that determines this. If there are more than 7, it will convert the notation.

For example (in jRuby 10):

irb(main):001> x = 1234567.1234567893
=> 1234567.1234567894
irb(main):002> x.to_json
=> "1234567.1234567894"
irb(main):003> x = 12345678.12345678912
=> 12345678.12345679
irb(main):004> x.to_json
=> "1.234567812345679E7"

Versus (in Ruby 3.4.1):

irb(main):001> x = 1234567.1234567893
=> 1234567.1234567894
irb(main):002> x.to_json
=> "1234567.1234567894"
irb(main):003> x = 12345678.12345678912
=> 12345678.12345679
irb(main):004> x.to_json
=> "12345678.12345679"

In particular, this causes issues with JSON output containing timestamps in epoch+milliseconds output, such as what you would get from Time.now.to_f.

Lenguaje dominante
Ruby
Estrellas
782
Forks
383
Merge medio
1 d 18 h
PR fusionados (30 d)
10

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ruby/json

Todos los issues de ruby/json

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.