I am using Perl 5.22.1 (Ubuntu 16.04 LTS) and am trying to understand why referencing a hash value changes the internal type of the value and how to identify what the type is in the first place. By way of example:
outputs 1~{"a":1}
outputs 1~{"a":"1"}
However,
outputs 1~{"a":"1"} NB {a=>1} at start
yet ostensibly no explicit change was made to $x{a} further more the reverse does not apply i.e. I can't change it back via reference only; such as print length($x{a}),$x{a}+0,... does not lead to encode_json(\%x) returning {"a":1}
So BUG, lack of understanding on my part? And how does one determin that $x{a} is a number verses a string?
As always, thanks in advance for any understanding shared.
For those that ask why do you want to know, becasue I am writting JSON to a field in MySQL Database which will be consumed via R (amongst other avenues) and in R "1"+1 -> ERROR. I need to ensure the JSON value pairs are consistent so it appears I need to be very careful (or use another version or Perl?) between generating the Hash and encoding it before writting to the Database.
In reply to Hash value typing by waynerasm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |