以下のJSON入力があります-
{"links":{"self":"/some/path"},"data": [{"type":"some_service","id":"foo","attributes": {"created":true ,"active":true,"suspended":false}}, {"type":"some_service","id":"dummy","attributes":{"created":false}}]}
私は以下のコードを使用しています -
use strict;
use warnings;
use JSON::XS;
use Data::Dumper;
my $result = decode_json($input);
print Dumper($result) . "\n";
しかし、私は出力を下回っています-
$VAR1 = {
'data' => [
{
'attributes' => {
'active' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ),
'created' => $VAR1->{'data'}[0]{'attributes'}{'active'},
'suspended' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' )
},
'id' => 'foo',
'type' => 'some_service'
},
{
'id' => 'dummy',
'attributes' => {
'created' => $VAR1->{'data'}[0]{'attributes'}{'suspended'}
},
'type' => 'some_service'
}
],
'links' => {
'self' => '/some/path'
}
};
'created' の値は $VAR1->{'data'}[0]{'attributes'}{'active'} のように見えますが、これは正確ではないようで、他の場所でも同じことが起こります。
コードのどこかが欠けているのでしょうか、それとも JSON 入力にエラーがありますか? ご提案をお寄せください。