You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing phpGPX with points from a database that contained timestamp, latitude, longitude and elevation and noticed that the JSON output had "null" in the elevation property. This is because the elevation was a string.
Remarkably enough, this problem did not occur when exporting to XML.
Package version: 1.0-RC5, also tested on dev-master
PHP version: 7.4.1
Expected behaviour
Silently cast the value to a float or null.
Possible solution
SerializationHelper::floatOrNull() should use is_numeric() instead of is_float() || is_integer()
Alternate solution
You could also throw an exception if the value is neither a float nor null. Maybe a 'strict mode' could be offered for people who prefer to get an exception.
The text was updated successfully, but these errors were encountered:
Hi,
I was testing phpGPX with points from a database that contained timestamp, latitude, longitude and elevation and noticed that the JSON output had "null" in the elevation property. This is because the elevation was a string.
Remarkably enough, this problem did not occur when exporting to XML.
Expected behaviour
Silently cast the value to a float or null.
Possible solution
SerializationHelper::floatOrNull()
should useis_numeric()
instead ofis_float() || is_integer()
Alternate solution
You could also throw an exception if the value is neither a float nor null. Maybe a 'strict mode' could be offered for people who prefer to get an exception.
The text was updated successfully, but these errors were encountered: