Parse and Encode JSON in Perl
Round-trip JSON with the JSON module: decode to a Perl hashref and re-encode.
Author:
chris
// Language: Perl
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
my $json_text = '{"name":"chris","langs":["perl","go"]}';
my $data = decode_json($json_text);
push @{ $data->{langs} }, 'rust';
print encode_json($data), "\n";