Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#817 コメント 3 件 リアクション 1 件 担当者 1 名 GitHub で見る

@headius がすでに取り組んでいます。

2025年8月25日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
Ruby
スター
782
フォーク
383
平均マージ
1日 18時間
マージ済み PR(30日)
10

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/json のほかの issue

ruby/json の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。