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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -