我是Perl的新手,我有一个非对称的JSON数组,如下所示:
[
{"KEY1":"14507226013384557","KEY2":"1234","KEY3":"7899"},
{"KEY1":"14507226013384557","KEY2":"1234","KEY3":"7899","KEY4":"TEST","KEY5":"TEST1"},
{"KEY1":"14507226013384557","KEY2":"1234","KEY3":"7899","KEY5":"TEST New"},
]
我想解析并将JSON数组存储在HASH列表中,然后迭代该哈希列表并检查每个KEY的值及其处理过程。任何想法我该怎么办?我使用过JSON解码并使用dumper打印,但是在迭代它时我遇到了问题。
答案 0 :(得分:4)
my $data = decode_json($json_utf8);
for my $row (@$data) {
for my $key (keys(%$row)) {
say "$key: $row->{$key}";
}
say "";
}
参考文献: