I am trying to assign the values to the variable from the subprocess.run() command my code below
import subprocess
import_json_names = 'fileb://xxx/yyyy.json'
output = subprocess.run(['aws', 'apigateway', 'import-rest-api', '--body', f'{import_json_names}', '--profile', 'xxxx'],capture_output=True,
text=True, check=True)
finaloutput = output.stdout
print(finaloutput)
after execute the above command, I m getting the following output
{
"id": "123abc444",
"name": "xxxx",
"description": "xxx yy",
"createdDate": "2022-06-06T13:41:44+05:30",
"version": "2021-05-31T18:09:59Z",
"apiKeySource": "HEADER",
"endpointConfiguration": {
"types": [
"EDGE"
]
},
"disableExecuteApiEndpoint": false
}
I want to extract "id" values from the above output how to achieve the same?
finaloutputas a python dictionary using thejsonmodule in python, specificallyjson.loads()print(json.loads(finaloutput)["id"])