Posts

Showing posts with the label JSON

Reading and writing JSON in Perl

Errata for  JavaScript JSON Cookbook  :  use JSON;  use Data::Dumper;  my $json = '{ "call":"KF6GPE","type":"l","time":"1399371514", "lasttime":"1418597513","lat": 37.17667,"lng": -122.14650, "result" : "ok" }';  my %result = decode_json($json);  print Dumper(result);  print encode_json(%result);  Fixed:  use strict;  use warnings;  use JSON;  use Data::Dumper;  # string json  my $json = '{ "call":"KF6GPE","type":"l","time":"1399371514", "lasttime":"1418597513","lat": 37.17667,"lng": -122.14650, "result" : "ok" }';  my $result = decode_json($json);  print Dumper($result);  print encode_json($json), "\n";  Output:  $VAR1 = { 'lat' => '37.17667', 'lasttime' => '141859751...