MCPcopy Create free account
hub / github.com/KoljaB/RealtimeVoiceChat / parse_json_message

Function parse_json_message

code/server.py:184–200  ·  view source on GitHub ↗

Safely parses a JSON string into a dictionary. Logs a warning if the JSON is invalid and returns an empty dictionary. Args: text: The JSON string to parse. Returns: A dictionary representing the parsed JSON, or an empty dictionary on error.

(text: str)

Source from the content-addressed store, hash-verified

182# Utility functions
183# --------------------------------------------------------------------
184def parse_json_message(text: str) -> dict:
185 """
186 Safely parses a JSON string into a dictionary.
187
188 Logs a warning if the JSON is invalid and returns an empty dictionary.
189
190 Args:
191 text: The JSON string to parse.
192
193 Returns:
194 A dictionary representing the parsed JSON, or an empty dictionary on error.
195 """
196 try:
197 return json.loads(text)
198 except json.JSONDecodeError:
199 logger.warning("🖥️⚠️ Ignoring client message with invalid JSON")
200 return {}
201
202def format_timestamp_ns(timestamp_ns: int) -> str:
203 """

Callers 1

process_incoming_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected