Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

Parsing JSON with Unix tools

$
0
0

I'm trying to parse JSON returned from a curl request, like so:

curl 'http://twitter.com/users/username.json' |    sed -e 's/[{}]/''/g' |     awk -v k="text"'{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'

The above splits the JSON into fields, for example:

% ..."geo_enabled":false"friends_count":245"profile_text_color":"000000""status":"in_reply_to_screen_name":null"source":"web""truncated":false"text":"My status""favorited":false% ...

How do I print a specific field (denoted by the -v k=text)?


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>