Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用sed从JSON响应中获取精确值_Json_Unix_Curl_Sed_Jq - Fatal编程技术网

使用sed从JSON响应中获取精确值

使用sed从JSON响应中获取精确值,json,unix,curl,sed,jq,Json,Unix,Curl,Sed,Jq,我从curl命令获取这个字符串数据 {"password": [["passwordreal", "2035/01/01 00:00"]], "user": "user1", "address": "kobebkokoko.net"} 如何使用sed获取passwordreal 比如说, curl xxxx | sed -n '/ *"password"' => Been working on this long hours. 与jq合作: | jq -r '.password[]|

我从
curl
命令获取这个字符串数据

 {"password": [["passwordreal", "2035/01/01 00:00"]], "user": "user1", "address": "kobebkokoko.net"}
如何使用
sed
获取
passwordreal

比如说,

curl xxxx | sed -n '/ *"password"' => Been working on this long hours.
与jq合作:

| jq -r '.password[]|.[0]'
输出:

passwordreal 密码实数

使用能够安全处理JSON的工具。sed不是其中之一。

如何修剪“”?如果您想获得
“passwordreal”
,请获取
“passwordreal”
删除
-r
.password[][0]
,或者实际需要的是:
.password[0][0]
关于“如何从JSON字符串中提取JSON值”的简短回答是“不使用
sed
——除非您有自己喜欢的替代JSON操纵器程序,否则请使用
jq
”。好的,它不是很短,但它切中要害。