mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Add support for JSON fragments (#107213)
This commit is contained in:
@ -45,6 +45,8 @@ def json_encoder_default(obj: Any) -> Any:
|
||||
|
||||
Hand other objects to the original method.
|
||||
"""
|
||||
if hasattr(obj, "json_fragment"):
|
||||
return obj.json_fragment
|
||||
if isinstance(obj, (set, tuple)):
|
||||
return list(obj)
|
||||
if isinstance(obj, float):
|
||||
@ -114,6 +116,9 @@ def json_bytes_strip_null(data: Any) -> bytes:
|
||||
return json_bytes(_strip_null(orjson.loads(result)))
|
||||
|
||||
|
||||
json_fragment = orjson.Fragment
|
||||
|
||||
|
||||
def json_dumps(data: Any) -> str:
|
||||
r"""Dump json string.
|
||||
|
||||
|
Reference in New Issue
Block a user