Decoding Hash from JSON-String in Perl -
why not work?
my $myhashencoded = encode_json \%myhash; %myhashdecoded = decode_json($myhashencoded);
i error:
reference found even-sized list expected @ ...
so changed to:
my $myhashencoded = encode_json \%myhash; $myhashdecoded = decode_json($enableinputencoded);
but %myhash
not same $myhashdecoded
.
how restore proper hash json string?
assuming using json.pm, the documentation says:
the opposite of encode_json: expects utf-8 (binary) string , tries parse utf-8 encoded json text, returning resulting reference.
so getting put in. you're putting in hashref , you're getting hashref back.
if want regular hash, dereference other hashref:
my $myhashrefdecoded = decode_json($myhashencoded); %myhashdecoded = %$myhashrefdecoded;
Comments
Post a Comment