Google Cloud Platform Tutorial Problem


I have a student who is working through rickkas7’sexcellent tutorial, and is having a problem with this line:

gcloud beta pubsub topics publish test2 --message ‘{“a”:123}’

In the logs, we see:

Unexpected token ’ in JSON at position 0.

If we change the message to anything else,the first character in that message is appears instead.

For example, --message X{“a”:123}


Unexpected token X in JSON at position 0.

The log references an error in line 26:22 in index.js, which is:

var jsonData = JSON.parse(Buffer.from(, 'base64').toString());

Any ideas or debugging strategies? This is not quite in my wheelhouse and GCP has a lot of moving parts.


It looks like the quotes got transformed from regular quotes ‘x’ and “x” to typographical quotes ‘x’ “x”. Only the straight quotes are allowed in JSON.


Thanks for your reply, rickkas7. I think the typographical quotes were just some sort of artifact … on his machine the quotes definitely appear to be straight: and if we put another leading character in the message instead (e.g., X{“a”:123}) it complains about that character being unexpected instead.


I think they might have changed the command syntax. You may need to add an equal sign and no spaces now.

gcloud beta pubsub topics publish test2 --message='{"a":123}'