Here is my Full Code. This script is triggered by a pub/sub in cloud functions, and parses out the message from the pub/sub by key, and value. for testing I have a sample string as the message in the code.
import base64
import os
import json
#import subprocess
#import shlex
def hello_pubsub(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
pubsub_message ='{"name": instance1, "zone": us-west1-c, "project": projectname}'
pubsub_json = json.loads(pubsub_message)
for key,value in pubsub_json.items():
print (key,value)
hello_pubsub('event', 'context')
However, when I run this, I get this error
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 10 (char 9)
Using debugger in VSCode, the error gets trigger by the json.loads line.
I have tried using different versions of json.loads and Im not sure why I get this error, when I use json.dumps I get a sting/integers error. Any Ideas?