|more useful options|
Did the JSON module change?by nilesOien (Novice)
|on Mar 01, 2018 at 17:07 UTC||Need Help??|
nilesOien has asked for the wisdom of the Perl Monks concerning the following question:
We have perl code that used to produce JSON that looked, in part, something like this :"count" : "3"
And then after installing a new module via cpanm, which caused a lot of updates, it produced JSON that looks like this :"count" : 3
Notice that there are no quotes around the number now. This caused much confusion as it caused the downstream parser of the JSON to choke. After a lot of chasing, it seems like after the update, if you do math with a hash reference, it changes the type of the variable from a string to a number, even if the hash reference is not used to store the output. It's probably best illustrated by the script below.
We are running on CentOS 6.8 with this perl :
What changed? Is it the JSON module? It seems like it used to make a number out of the string in a temporary way, do math with it, and then discard that number, but now it actually changes the type of the hash reference. And is this new way the desired behavior? Is this change documented? It was hard to figure out in our case.
Thanks, all - Niles Oien.