mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 09:46:29 +00:00
Print error on invalid json (#263)
This commit is contained in:
parent
747810b729
commit
8f94b4d63f
@ -17,10 +17,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def json_loads(data):
|
def json_loads(data):
|
||||||
"""Extract json from string with support for '' and None."""
|
"""Extract json from string with support for '' and None."""
|
||||||
|
if not data:
|
||||||
|
return {}
|
||||||
try:
|
try:
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
return {}
|
raise RuntimeError("Invalid json")
|
||||||
|
|
||||||
|
|
||||||
def api_process(method):
|
def api_process(method):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user