我有这个JSON文件:
{
"range": "Sheet!A2:B100",
"majorDimension": "ROWS",
"values": [
[
"customer1_name",
"customer1@email.com",
"customer1_phone",
"customer1_city"
],
[
"customer2_name",
"customer2@email.com",
"customer2_phone",
"customer2_city"
]
]
}
并且,从一个外壳脚本中,我想使用JQ来提取每个块的每个值,并将它们赋给一些变量。以下是预期结果:
对于此区块:
[
"customer1_name",
"customer1@email.com",
"customer1_phone",
"customer1_city"
],
结果应该是这样的:
VAR1 = "customer1_name"
VAR2 = "customer1@email.com"
VAR3 = "customer1_phone"
VAR4 = "customer1_city"
对于这个街区:
[
"customer2_name",
"customer2@email.com",
"customer2_phone",
"customer2_city"
],
结果应该是这样的:
VAR1 = "customer2_name"
VAR2 = "customer2@email.com"
VAR3 = "customer2_phone"
VAR4 = "customer2_city"
其思想是逐块读取JSON文件,以获取/检索vars中的所有值。
1条答案
按热度按时间7cwmlq891#
像这样使用
tr
有点老套,但是:您还可以执行以下操作: