How do I convert a blessed object into JSON in Perl? Following is the array I have:
@x = ({
'notificationtype' => 'TRAP',
'receivedfrom' => 'UDP: [10.127.34.212]:48909->[10.127.34.182]:162',
'version' => 1,
},
[
[
bless( {
'oidptr' => bless( do{\(my $o = '140059234062224)}, ''netsnmp_oidPtr' )
}, 'NetSNMP::OID' ),
'600',
67
],
[
bless( {
'oidptr' => bless( do{\(my $o = '140059236784112)}, ''netsnmp_oidPtr' )
}, 'NetSNMP::OID' ),
'OID: .iso.org.dod.internet.private.enterprises.14296.1.100.0.0.1',
6
]
]);
I am able to convert $VAR1
alone using encode_json \@x
, but when I the use the blessed object, it's not working. I am getting the error:
encountered object 'NetSNMP::OID=HASH(0x136b278)', but neither allow_blessed nor convert_blessed settings are enabled at u.pl line 256.
I expected a serialized JSON object so that I can send it over to server.
How can I do it?