gsutil produces stdout output in it's custom key-value format which is quite inconvenient to parse. Is it possible to make gsutil generate JSON instead e.g. for this command:
gsutil ls -L gs://bucket-name/relative/path
The output will be in something that is closer to be yaml format. as mentioned in the code on the official GitHub repository and as part of gsutil
the output format cannot be modified.
the output will be something like:
gs://bucket/ :
Storage class: STANDARD
Location constraint: US
Versioning enabled: False
Logging configuration: None
Website configuration: None
CORS configuration: None
Lifecycle configuration: None
Requester Pays enabled: True
Labels: None
Default KMS key: None
Time created: Thu, 14 Jan 2016 19:25:17 GMT
Time updated: Thu, 08 Jun 2017 21:17:59 GMT
Metageneration: 1
Bucket Policy Only enabled: False
ACL:
[
{
"entity": "project-owners-867489160491",
"projectTeam": {
"projectNumber": "867489160491",
"team": "owners"
},
"role": "OWNER"
}
]
Default ACL:
[
{
"entity": "project-owners-867489160491",
"projectTeam": {
"projectNumber": "867489160491",
"team": "owners"
},
"role": "OWNER"
}
]
To get this as JSON i found this go repository that can work for encode the output as a JSON
git clone https://github.com/fedir/json_encode.git
cd json_encode
go build
gsutil ls -L gs://bucket-name | ./json_encode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With