khrt / Raisin

Raisin - a REST API micro framework for Perl 🐫 🐪
61 stars 29 forks source link

Regex check in Raisin::Entity flags numbers as strings for JSON::XS #114

Open m-dango opened 2 years ago

m-dango commented 2 years ago

Raisin::Entity::_compile_column contains the following check on an entity runtime return value:

$retval && !ref($retval) && $retval =~ /^Raisin::Entity::Nested::/

The checks on $retval unfortunately means that any non-zero value returned as a number from the runtime will be output as a string in JSON, due to the regex, if the user happens to be using JSON::XS.

Raisin example: https://replit.com/@m-dango/RaisinNumericString#main.pl

Comparing resulting JSON across different modules: https://replit.com/@m-dango/jsonNumberRegex#main.pl