I am very new to JSON. I ran some commands and stored its output in string. Now i want to convert it into JSON. How can i convert it into perl hash referencces and then convert i into JSON. My output is like this but this is in string format :-
{"limits": {"rate": [], "absolute": {"maxServerMeta": 128, "maxPersonality": 5, "maxImageMeta": 128, "maxPersonalitySize": 10240, "maxSecurityGroupRules": 20, "maxTotalKeypairs": 100, "totalRAMUsed": 6144, "totalInstancesUsed": 3, "maxSecurityGroups": 10, "totalFloatingIpsUsed": 0, "maxTotalCores": 20, "totalSecurityGroupsUsed": 0, "maxTotalFloatingIps": 10, "maxTotalInstances": 10, "totalCoresUsed": 6, "maxTotalRAMSize": 51200}}}
I am using this code:-
my %hash_ref = split /[,:]/, $curl_cmd3_output;
my $h = from_json( $hash_ref ); #<-- $h is a perl hash reference
print $h;
$max= $h->{'limits'}{'absolute'}{'maxSecurityGroupRules'}, "\n"; #<-- 20
print $max;
But i am getting this error
hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)
How to solve it ?