in reply to Re^2: String to Integer, for json file
in thread String to Integer, for json file
"...could you try this out?"
Why not, nice invitation:
karls-mac-mini:monks karl$ perl -MData::Dumper -e '$hash{'cl_ip'} = "2 +9988" + 0;print Dumper(\%hash);'$VAR1 = { 'cl_ip' => 29988 };
But: so what ;-)
Update:
D'oh! Mille Regretz!
#!/usr/bin/env perl + use JSON::XS; use Data::Dumper; my %hash = ( cl_ip => 209890 ); my $json = encode_json \%hash; print Dumper( \%hash ); print qq($json\n); $hash{ cl_ip } += 0; $json = encode_json \%hash; print Dumper( \%hash ); print qq($json\n); __END__ karl-mac-mini:monks karl$ ./json.pl + $VAR1 = { + 'cl_ip' => 209890 + }; + {"cl_ip":209890} + $VAR1 = { + 'cl_ip' => 209890 + }; + {"cl_ip":209890}
Update2:
#!/usr/bin/env perl + use JSON::XS; use Data::Dumper; my %hash = ( cl_ip => 209890 ); my $json = encode_json \%hash; print Dumper( \%hash ); print qq($json\n); $hash{ cl_ip } += 0; $json = encode_json \%hash; print Dumper( \%hash ); print qq($json\n); $hash{ cl_ip } = "209890"; $json = encode_json \%hash; print Dumper( \%hash ); print qq($json\n); __END__ $VAR1 = { 'cl_ip' => 209890 }; {"cl_ip":209890} $VAR1 = { 'cl_ip' => 209890 }; {"cl_ip":209890} $VAR1 = { 'cl_ip' => '209890' }; {"cl_ip":"209890"}
I'll give it up for tonight before i produce more shit...
Update3:
I'll give it up...
I don't:
#!/usr/bin/env perl use JSON::XS; use Data::Dumper; use strict; use warnings; my %hash = ( cl_ip => 209890 ); print Dumper( \%hash ); print qq(\n); my $json = encode_json \%hash; print qq($json\n\n); #------------------------------ $hash{cl_ip} += 0; print Dumper( \%hash ); print qq(\n); $json = encode_json \%hash; print qq($json\n\n); #------------------------------ $hash{cl_ip} = "209890"; print Dumper( \%hash ); print qq(\n); $hash{cl_ip} += 0; print Dumper( \%hash ); print qq(\n); $json = encode_json \%hash; print qq($json\n\n); __END__ karl-mac-mini:monks karl$ ./json.pl $VAR1 = { 'cl_ip' => 209890 }; {"cl_ip":209890} $VAR1 = { 'cl_ip' => 209890 }; {"cl_ip":209890} $VAR1 = { 'cl_ip' => '209890' }; $VAR1 = { 'cl_ip' => 209890 }; {"cl_ip":209890}
My best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|