I have a string like this below ( basically response of an HTTP request ).
response={"@base":"http://localhost:8080/hello/stackoverflow/","updated":"2016-01-20T17:12:02.284Z","links":[{"rel":"self","href":"/0"}],"content":{"id":"0","enabled":true}}
Now i have a shell script where i am capturing this http response and parsing this just to extract value of variable 'enabled' here. I have this code written but it does seems to be working. I am very new to shell so not really sure if i am doing something completely wrong or missing any specific detail.
enabled=$(echo $response | awk -F"," '/content/ {
for( i=1; i < NF; i++) {
if( match( $i, /enabled/) ){
split( $i, a, ":")
print a[length(a)]
}
}
}')
Can someone suggest best way to do it or any other suggestion to capture the value of tag 'enabled' in response of http request. enabled tag will always be present under tag 'content'
NOTE: I did researched and try understanding the shell script. This is how i was able to write the above code. but something does not seems to be correct so i never get the value of the tag enabled.
Any guidance or suggestion is appreciated