File tree 1 file changed +6
-13
lines changed
1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -122,19 +122,12 @@ class RubyObjectEncoder {
122
122
}
123
123
}
124
124
} else {
125
- // HACK: for standard notation we can use the RapidJSON
126
- // implementation, but for values we need scientific notation we
127
- // will fallback to Ruby's to_s so that we match JSON's output
128
- // exactly.
129
- //
130
- // Ideally we would just implement both
131
- if (f <= -1.0e15 || f >= 1.0e15 || (f >= -0.0001 && f <= 0.0001 )) {
132
- VALUE str = rb_funcall (v, rb_intern (" to_s" ), 0 );
133
- Check_Type (str, T_STRING);
134
- encode_raw_json_str (str);
135
- } else {
136
- writer.Double (f);
137
- }
125
+ // TODO: We should avoid relying on to_s and do this conversion
126
+ // ourselves. However it's difficult to get the exact same rounding
127
+ // and truncation that Ruby uses.
128
+ VALUE str = rb_funcall (v, rb_intern (" to_s" ), 0 );
129
+ Check_Type (str, T_STRING);
130
+ encode_raw_json_str (str);
138
131
}
139
132
}
140
133
You can’t perform that action at this time.
0 commit comments