我有下面的curl请求,并附上响应的响应,我需要提取"status.azure.resource_name“的值,我是GitHub操作的新手,因此从8小时以上一直坚持这个问题,如果它是我现在已经解决的一些编程语言,请帮助它。
卷曲请求:
curl --location --request PUT $URL \
--header "$AUTH_HEADER" \
--header 'Content-Type: application/json' \
--data-raw "$PAYLOAD)"以及答复:
{
"labels": {},
"spec": {
"mysql": {
"version": "8.0",
"sku": {
"name": "GP_Gen5_4"
},
"storage_profile": {
"storage_mb": 5120
}
},
"key_vault": {
"access_policies": [
{
"name": "test",
"type": "group",
"project": null
}
]
}
},
"type": "azure-mysql",
"name": "mysql",
"id": "1234",
"created_at": "2012-03-04T10:00:05+00:00",
"updated_at": "2012-03-04T10:00:05+00:00",
"project": {
"id": "ae3dfa99",
"name": "Test",
"url": "www.google.com",
"geography": "in"
},
"links": {
"key_vault": {
"endpoint": {
"url": "",
"description": "test.",
"display_name": "test"
},
"azure_portal": {
"url": "test",
"description": "Link to the resource in the Azure portal.",
"display_name": "Key Vault Azure Portal"
}
},
"azure_portal": {
"url": "test",
"description": "Link to the resource in the Azure portal.",
"display_name": "Azure Portal"
},
"endpoint": {
"url": "test",
"description": "Azure resource endpoint.",
"display_name": "test"
}
},
"url": "test",
"tags": {
"cost_center_id": "471000",
"customer": "internal",
"product_group": "internal",
"environment_type": "test",
"budget_category": "",
"team": ""
},
"spiffe_id": "test",
"status": {
"ready": false,
"state": "reconciling",
"deployment": {
"steps": {}
},
"azure": {
"resource_name": "test",
"id": null,
"subscription_id": "test",
"resource_group": "test"
},
"key_vault": {
"access_policies": []
}
}
}发布于 2022-03-05 17:30:51
您只需使用jq来执行json解析。它已经可以使用在github动作跑步者中了。
在您的例子中,应该是这样的(我将您的响应json粘贴到test.json文件中)
$ cat test.json | jq .status.azure.resource_name
"test"https://stackoverflow.com/questions/71359333
复制相似问题