簡體   English   中英

如何使用shell腳本打印解析Json

[英]How to print parse Json using shell script

我如何使用 grep awk 打印只是為了從下面的字符串打印成功。

{“身份”:“2320147”,“身份驗證”:“成功”}

使用GNU awk

echo "{"identity":"2320147","authentication":"success"}" |awk -F "[:}]" '{print $3}'

輸出:

success

使用jq

test='{"identity":"2320147","authentication":"success"}'

$ jq -r '.authentication' <<< $test
success

JQ的幫助

$ jq -h
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
...
     -r     output raw strings, not JSON texts;
...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM