【发布时间】:2015-09-22 06:44:08
【问题描述】:
我有一个像
这样的 JSON 对象 {
"Men": [
"All Clothing",
"All Clothing",
"All footwear",
"All footwear",
"All Watches",
"All Watches",
"All Sunglasses",
"All Sunglasses"
],
"Electronics": [
"Mobiles",
"Tablets",
"Wearable Smart Devices",
"Mobile Accessories",
"Headphones and headsets",
"Tablet Accessories",
"Computer Accessories",
"Televisions",
"Large Appliances",
"Small Appliances",
"Kitchen Appliances",
"Personal Care",
"Audio and video",
"Laptop"
],
"Women": [
"Ethnic wear",
"Western wear",
"Lingerie & Sleep Wear",
"All Bags, Belts & Wallets",
"All jewellery",
"All Perfumes",
"Spectacle Frames",
"Beauty & Personal Care",
"The International Beauty Shop"
]
}
我想使用 jq 过滤器从这个 object.m 中获取键值对,但它不起作用。
keys=`jq 'keys' $categories`
$categories 是 json 对象的变量名。欢迎提出建议。
【问题讨论】: