I am very new to perl so please help me out in following
I have one perl script to execute telnet command. This script receives response from server as string. Actually server create a json string and then it sends to client program but client program is showing it as string
Question : How I can convert this string to json and read data from this json string.
I have json string with structure similar to following
[{"success":"21","data":[{"name":"tester","lastname":"project"}]}]
Following are the last lines where I have tried to convert it to json
@lines = $telnet->waitfor('/$/');
my @json;
@json = @{decode_json(@lines)};
It prints output as below
HASH(0x1af068c)
Thanks in advance !!!
I think there is a simpler one:
Here is a snippet to convert the JSON. Modified to catch errors.