【发布时间】:2016-10-09 04:57:50
【问题描述】:
我正在使用jq 重新格式化我的JSON。
JSON 字符串:
{"channel": "youtube", "profile_type": "video", "member_key": "hello"}
想要的输出:
{"channel" : "profile_type.youtube"}
我的命令:
echo '{"channel": "youtube", "profile_type": "video", "member_key": "hello"}' | jq -c '. | {channel: .profile_type + "." + .member_key}'
我知道下面的命令连接字符串。但它的工作逻辑与上述不同:
echo '{"channel": "youtube", "profile_type": "video", "member_key": "hello"}' | jq -c '.profile_type + "." + .member_key'
我怎样才能只使用 jq 来实现我的结果?
【问题讨论】:
-
我想我正在尝试用我的 youtube API 脚本做同样的事情;)