xonsh/xonsh/jsonutils.py
pre-commit-ci[bot] 66c0490d37
[pre-commit.ci] pre-commit autoupdate (#5271)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-30 12:23:50 +01:00

20 lines
457 B
Python

"""Custom tools for managing JSON serialization / deserialization of xonsh
objects.
"""
import functools
from xonsh.tools import EnvPath
@functools.singledispatch
def serialize_xonsh_json(val):
"""JSON serializer for xonsh custom data structures. This is only
called when another normal JSON types are not found.
"""
return str(val)
@serialize_xonsh_json.register(EnvPath)
def _serialize_xonsh_json_env_path(val):
return val.paths