问题:
I'm trying to parse JSON returned from a curl request, like so: 我正在尝试解析从curl请求返回的JSON,如下所示:
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: 上面将JSON分为多个字段,例如:
% ...
"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 -vk=text
)? 如何打印特定字段(由-vk=text
)?
解决方案:
参考一: https://stackoom.com/question/8CiP/使用Unix工具解析JSON参考二: https://oldbug.net/q/8CiP/Parsing-JSON-with-Unix-tools
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4328150