josn转指定key的键值对:
echo "$hhhkkkk"
{
"self_id": 3567435297,
"user_id": 3237476277,
"time": 1723968906,
"message_id": 2066614224,
"message_seq": 2066614224,
"real_id": 2066614224,
"message_type": "group",
"sender": {
"user_id": 3237476277,
"nickname": "。",
"card": "不是隔壁小王-我要踢人",
"role": "admin"
},
"raw_message": "这个应该没锁,有人卖599的,说的没锁",
"font": 14,
"sub_type": "normal",
"message": [
{
"data": {
"text": "这个应该没锁,有人卖599的,说的没锁"
},
"type": "text"
}
],
"message_format": "array",
"post_type": "message",
"group_id": 156131290
}
echo "$hhhkkkk"|jq -r '. | "user_id=\"\(.user_id)\";time=\"\(.time)\";real_id=\"\(.real_id)\""'
user_id="3237476277";time="1723968906";real_id="2066614224"
json转所有键值对
echo "$hhhkkkk"|jq -r 'to_entries[] | "\(.key)=\"\(.value | tostring)\""'
self_id="3567435297"
user_id="3237476277"
time="1723968906"
message_id="2066614224"
message_seq="2066614224"
real_id="2066614224"
message_type="group"
sender="{"user_id":3237476277,"nickname":"。","card":"不是隔壁小王-我要踢人","role":"admin"}"
raw_message="这个应该没锁,有人卖599的,说的没锁"
font="14"
sub_type="normal"
message="[{"data":{"text":"这个应该没锁,有人卖599的,说的没锁"},"type":"text"}]"
message_format="array"
post_type="message"
group_id="156131290"