There's more than one way to do things | |
PerlMonks |
Re: Data::Dumper turns floating points numbers into stringsby ig (Vicar) |
on Jun 14, 2011 at 18:43 UTC ( [id://909626]=note: print w/replies, xml ) | Need Help?? |
Note that this effect isn't unique to Data::Dumper. Any operation that stringifies a number or integer will change how JSON (the pure Perl implementation, I didn't look at the XS) represents it.
gives
This problem isn't unique to JSON either. I have seen similar issues in Win32::OLE, for example. Anything that inspects the scalar type and behaves differently depending on what it finds must resolve the ambiguity, shown by ikegami / Devel::Peek, that sometimes exists. When using such modules, you must be careful with your data. One way to avoid the problem would be to make a copy of your data and stringify the copy.
In Section
Seekers of Perl Wisdom
|
|