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

hmepas hmepas at gmail.com
Sun Dec 7 08:58:17 GMT 2014


Imagine the same service serving xml and json. It's come in handy to use
WSDL validation for both protocols to avoid code duplication. Then if we
converting to json structure which came out after XML::Compile
deserialization, floats and decimals will be like "3.14". And then if you
will serve this json to the strict languages like i.e. Java you might have
problems (depends on host strict is json realization).
And if integers are going thru $_[0] += 0, why not doing the same for float
types, when sloppy_floats is on?
I solved my problem via redefining
$XML::Compile::Schema::BuiltInTypes::builtin_types{sloppy_float}
right in my controller, but it you will change this realization in future
versions of XML::Compile, my code will broke. Yes, I could have a unit test
for that, but still.



On Sun, Dec 7, 2014 at 3:10 AM, Mark Overmeer <mark at overmeer.net> wrote:

> * hmepas (hmepas at gmail.com) [141206 21:13]:
> > I stumbled into annoying problem. When I deserializing my XML, I am
> getting
> > integers as Perl integers, while anything what's sloppy_floats became
> > strings.
>
> You are correct.  However, can you explain me why this is an annoying
> problem for you?  Perl converts strings into floats all the time.
> --
> 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/20141207/3cec858a/attachment.htm>


More information about the Xml-compile mailing list