I am doing some json parsing in a bash script:
curl http://myurl.com/get.json | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | grep '"key":' | sed 's/:/ /1' | awk -F" " '{ print $2 }' | tr -d "\""
Now I want to take this to AppleScript but I’m a little confused with the escaping.
When I escpape all the " so I get this:
do shell script "curl http://myurl.com/get.json | sed -e 's/[{}]/''/g' | awk -v k=\"text\" '{n=split($0,a,\",\"); for (i=1; i<=n; i++) print a[i]}' | grep '\"key\":' | sed 's/:/ /1' | awk -F\" \" '{ print $2 }' | tr -d \"\"\""
it returns an error:
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
I’d really appreciate some help here! Thanks!
You were close – the escape character also needs to be escaped in that last bit:
Edit: I thought I got them all, but it looks like there may be an extra \” needed in that last bit.