[Xml-compile] $_[0] + 0.0 for sloppy floats
hmepas
hmepas at gmail.com
Tue Dec 16 12:29:49 GMT 2014
Thanks for the notice about my patch, i'll try to find a way around.
Talking about JSON, I am not seeing any other options actually, than
looking into SV. It's the only way to check type of the scalar, beside
having scalar stored into object. So the options are:
* having objects (slow down and overcomplicate things);
* having everything stringified in json;
* look into SV.
Bonus option: use language with strict types.
About making every key in json a string
{ "MapPoint" : { x : "10.2", y : "45.9" } }
this json code will break deserialization for strict typing languages like,
java. If x and y is floats in java.
Do I miss something?
On Tue, Dec 16, 2014 at 3:07 PM, Mark Overmeer <mark at overmeer.net> wrote:
>
> * 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
>
>
--
Pavel S. Khmelinsky <hmepas at gmail.com>
Jabber: hmepas at gmail.com
Skype: hmepas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20141216/e0aed580/attachment.htm>
More information about the Xml-compile
mailing list