[Xml-compile] $_[0] + 0.0 for sloppy floats

Mark Overmeer mark at overmeer.net
Tue Dec 16 12:07:23 GMT 2014


* Mark Overmeer (mark at overmeer.net) [141207 12:57]:
> * hmepas (hmepas at gmail.com) [141207 08:58]:
> > Then if we converting to json structure which came out after XML::Compile
> > deserialization, floats and decimals will be like "3.14".
> 
> The patch is accepted for next release.

I have to revert the change, triggered by a failing regression test.

When I read the JSON docs:
   my $value = 5; encode_json [$value]  # yields [5]

   # used as string, so dump as string
   print $value;
   encode_json [$value]                 # yields ["5"]

Your patch does work for simple floats in the XML, but it will not
work for floats which have additional facets (totalDigits, fracDigits,
length).  Those checks are done after stringification.

So, your patch does break validation for everyone.  Any use of facets
will break your JSON trick.  So: your patch does not work.  Sorry.

It would be nice to add an option to JSON to disable its "smart"
behavior.  Application libraries should not look into the SV!
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list