最佳答案
我使用 jq
来重新格式化我的 JSON
。
JSON String:
{"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}'
I know that the command below concatenates the string. But it is not working in the same logic as above:
echo '{"channel": "youtube", "profile_type": "video", "member_key": "hello"}' | jq -c '.profile_type + "." + .member_key'
How can I achieve my result using ONLY jq?