I was given the following event as a sample from another team... but this json is an invalid format (has single quotes) am i missing something ? schema here topics shows them up in double quotes.
How is it possible that the events we are getting for the following topic or others were returned with single quotes? We are not doing anything, receiving as it is.
Where are you getting that from? Whatever is providing that is probably what's responsible for malforming the JSON. Try using a different language or websocket library to verify that you get valid JSON there and the issue exists with your code.
This is due to Python.
This is because you are not using JSON encoder/decoder properly for the variable that you are printing.
Taking the listen_to_Websocket as an example (from the tutorial you are referencing above):
async def listen_to_Websocket():
""" Open a new web socket using the connect Uri of the channel """
async with websockets.connect(new_channel.connect_uri) as websocket:
print("Listening to websocket")
""" Message received """
async for message in websocket:
message = json.loads(message)
print("This will print with single quotes:")
print(message)
print("This will print with double quotes:")
print(json.dumps(message))