1"""Custom tools for managing JSON serialization / deserialization of xonsh 2objects. 3""" 4import functools 5 6from xonsh.tools import EnvPath 7 8 9@functools.singledispatch 10def serialize_xonsh_json(val): 11 """JSON serializer for xonsh custom data structures. This is only 12 called when another normal JSON types are not found. 13 """ 14 return str(val) 15 16 17@serialize_xonsh_json.register(EnvPath) 18def _serialize_xonsh_json_env_path(val): 19 return val.paths 20