json_object function drops leading zero for small fractional numbers (bug?)
I noticed something peculiar in the way fractional numbers are treated by the json_object sql function.
When the fractional number is smaller than 0.1, the leading zero is dropped from the result.
For values equal to or greater than 0.1, the leading zero is included.
select json_object( key 'test1' value 0.01
, key 'test2' value 0.05
, key 'test3' value 0.09
, key 'test4' value 0.10
, key 'test5' value 0.99 )
from dual;
{
"test1":.01,
"test2":.05,
"test3":.09,
"test4":0.1,
"test5":0.99
}
The obvious work-around for this problem is applying string-manipulation on the result of the json_object function => replace(replace(<json_object result>, ':.0', ':0.0'), ':-.0', ':-0.0')