use strict;
use warnings;
use JSON;
my $input='{"dns_zone": {"created_at":"2013-07-08T02:21:57-05:00","id"
+:752,"name":"aresstest.com","updated_at":"2013-07-08T02:21:57-05:00",
+"user_id":136,"records":{"SOA":[{"dns_record":{"expire":2419200,"host
+master":"ns1.qwkdns.com","id":122329,"minimum":10800,"name":"@","prim
+aryNs":"ns1.qwkdns.com","refresh":7200,"retry":900,"serial":201303211
+2,"ttl":86400,"type":"SOA"}}], "NS":[{"dns_record":{"hostname":"ns1.
+qwkdns.com","id":122325,"name":"aresstest.com","ttl":86400,"type":"NS
+"}},{"dns_record":{"hostname":"ns2.qwkdns.com","id":122326,"name":"ar
+esstest.com","ttl":86400,"type":"NS"}},{"dns_record":{"hostname":"ns3
+.qwkdns.com","id":122327,"name":"aresstest.com","ttl":86400,"type":"N
+S"}},{"dns_record":{"hostname":"ns4.qwkdns.com","id":122328,"name":"a
+resstest.com","ttl":86400,"type":"NS"}}], "A":[{"dns_record":{"id":1
+22332,"ip":"173.236.102.246","name":"localhost.aresstest.com","ttl":1
+4400,"type":"A"}},{"dns_record":{"id":122333,"ip":"173.236.102.246","
+name":"ftp","ttl":14400,"type":"A"}},{"dns_record":{"id":122334,"ip":
+"173.236.36.138","name":"mail","ttl":14400,"type":"A"}},{"dns_record"
+:{"id":122335,"ip":"173.236.102.246","name":"webmail","ttl":14400,"ty
+pe":"A"}},{"dns_record":{"id":122337,"ip":"173.236.36.138","name":"au
+todiscover","ttl":14400,"type":"A"}}], "CNAME":[{"dns_record":{"host
+name":"aresstest.com","id":122336,"name":"www","ttl":14400,"type":"CN
+AME"}}], "MX":[{"dns_record":{"hostname":"mail.aresstest.com","id":1
+22330,"name":"@","priority":0,"ttl":14400,"type":"MX"}}], "TXT":[{"d
+ns_record":{"id":122331,"name":"@","ttl":14400,"txt":"v=spf1 ip4:173.
+236.102.246 +a +mx +ip4:173.236.36.138 ?all","type":"TXT"}}]}}}';
my $output = to_json [ map { @$_ } values %{ (from_json $input)->{dns_
+zone}->{records} } ];
$output =~ s/{"dns/\n {"dns/g; # beautifying only, can be removed
$output =~ s/\]/\n]/; # beautifying only, can be removed
print $output;
Outout is
[
{"dns_record":{"priority":0,"ttl":14400,"name":"@","type":"MX","id":
+122330,"hostname":"mail.aresstest.com"}},
{"dns_record":{"ttl":14400,"ip":"173.236.102.246","name":"localhost.
+aresstest.com","type":"A","id":122332}},
{"dns_record":{"ttl":14400,"ip":"173.236.102.246","name":"ftp","type
+":"A","id":122333}},
{"dns_record":{"ttl":14400,"ip":"173.236.36.138","name":"mail","type
+":"A","id":122334}},
{"dns_record":{"ttl":14400,"ip":"173.236.102.246","name":"webmail","
+type":"A","id":122335}},
{"dns_record":{"ttl":14400,"ip":"173.236.36.138","name":"autodiscove
+r","type":"A","id":122337}},
{"dns_record":{"ttl":14400,"name":"@","type":"TXT","txt":"v=spf1 ip4
+:173.236.102.246 +a +mx +ip4:173.236.36.138 ?all","id":122331}},
{"dns_record":{"ttl":14400,"name":"www","type":"CNAME","id":122336,"
+hostname":"aresstest.com"}},
{"dns_record":{"ttl":86400,"name":"aresstest.com","type":"NS","id":1
+22325,"hostname":"ns1.qwkdns.com"}},
{"dns_record":{"ttl":86400,"name":"aresstest.com","type":"NS","id":1
+22326,"hostname":"ns2.qwkdns.com"}},
{"dns_record":{"ttl":86400,"name":"aresstest.com","type":"NS","id":1
+22327,"hostname":"ns3.qwkdns.com"}},
{"dns_record":{"ttl":86400,"name":"aresstest.com","type":"NS","id":1
+22328,"hostname":"ns4.qwkdns.com"}},
{"dns_record":{"minimum":10800,"ttl":86400,"serial":2013032112,"host
+master":"ns1.qwkdns.com","primaryNs":"ns1.qwkdns.com","name":"@","ret
+ry":900,"refresh":7200,"type":"SOA","id":122329,"expire":2419200}}
]
|