Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions java/src/json/ext/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,14 @@ static void generateFloat(ThreadContext context, Session session, RubyFloat obje
return;
}
}

throw Utils.buildGeneratorError(context, object, object + " not allowed in JSON").toThrowable();
}
}

buffer.write(Double.toString(value).getBytes(UTF_8));
ByteList tmp = new ByteList(24);
RubyFloat.formatFloat(object, tmp);
buffer.write(tmp.getUnsafeBytes(), tmp.getBegin(), tmp.getRealSize());
}

private static final byte[] EMPTY_ARRAY_BYTES = "[]".getBytes();
Expand Down
7 changes: 1 addition & 6 deletions test/json/json_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -998,12 +998,7 @@ def test_json_generate_float
assert_float_roundtrip "12.0", 12.0
assert_float_roundtrip "100.0", 100.0
assert_float_roundtrip "1000.0", 1000.0

if RUBY_ENGINE == "jruby"
assert_float_roundtrip "1.7468619377842371E9", 1746861937.7842371
else
assert_float_roundtrip "1746861937.7842371", 1746861937.7842371
end
assert_float_roundtrip "1746861937.7842371", 1746861937.7842371

if RUBY_ENGINE == "ruby"
assert_float_roundtrip "100000000000000.0", 100000000000000.0
Expand Down
Loading