-
Knut Anders Hatlen authored
TO INTEGERS When a JSON document is converted to string representation, floating-point values that have no fractional part may be represented in a format indistinguishable from integers. If the string representation of such a JSON document is passed through the JSON parser again, the information that the numeric value was originally specified as a floating-point value, is lost. The reason is that the conversion from JSON to string uses my_gcvt() to format floating-point values, and my_gcvt() does not add a decimal point if the value has no fractional part. This patch adds a fractional part to the string representation of floating-point values in JSON documents if the value has no fractional part and it is not represented in scientific format. This makes floating-point values distinguishable from integers in the string representation, so that they will stay as floating-point numbers if the string is parsed again. The patch also makes ST_GeomFromGeoJSON use the same JSON parser as the other JSON functions. It has used its own custom parser since bug#19504183 because ST_AsGeoJSON would drop the fractional part of negative zero (-0 instead of -0.0), and the JSON parser would interpret -0 as the integer 0 and lose the distinction between positive and negative zero. Since ST_AsGeoJSON now presents negative zero as -0.0, no special logic is needed in ST_GeomFromGeoJSON to preserve negative zeros when parsing the output from ST_AsGeoJSON. Change-Id: I20508741c981cc2ca2af004757f95ef78558f582
Knut Anders Hatlen authoredTO INTEGERS When a JSON document is converted to string representation, floating-point values that have no fractional part may be represented in a format indistinguishable from integers. If the string representation of such a JSON document is passed through the JSON parser again, the information that the numeric value was originally specified as a floating-point value, is lost. The reason is that the conversion from JSON to string uses my_gcvt() to format floating-point values, and my_gcvt() does not add a decimal point if the value has no fractional part. This patch adds a fractional part to the string representation of floating-point values in JSON documents if the value has no fractional part and it is not represented in scientific format. This makes floating-point values distinguishable from integers in the string representation, so that they will stay as floating-point numbers if the string is parsed again. The patch also makes ST_GeomFromGeoJSON use the same JSON parser as the other JSON functions. It has used its own custom parser since bug#19504183 because ST_AsGeoJSON would drop the fractional part of negative zero (-0 instead of -0.0), and the JSON parser would interpret -0 as the integer 0 and lose the distinction between positive and negative zero. Since ST_AsGeoJSON now presents negative zero as -0.0, no special logic is needed in ST_GeomFromGeoJSON to preserve negative zeros when parsing the output from ST_AsGeoJSON. Change-Id: I20508741c981cc2ca2af004757f95ef78558f582
Loading