gcloud publish Pub/Sub JSON message where JSON properties contain space characters

  Kiến thức lập trình

I have a JSON file named countries/list.json I want to publish the content with gcloud CLI.

{
  "countries": [
   {
      "id": "SE",
      "name": "Sweden"
    },
    {
      "id": "UK",
      "name": "United Kingdom"
    }
  ]
}

Accoring to the CLI docs I should be able to use

gcloud pubsub topics publish projects/<PROJECT>/topics/<TOPIC>--message=$(jq -c "." countries/list.json) --attribute "Content-Type=application/json"

This results in

ERROR: (gcloud.pubsub.topics.publish) unrecognized arguments: Kingdom"}]} 

If I change "United Kingdom" to "United-Kingdom" it works, but that is not what I want.

2

LEAVE A COMMENT