# Path: foil/deserializers.py
# def make_json_decoder_hook(str_decoders=STRING_DECODERS,
#                            extra_str_decoders=tuple(),
#                            converters=MappingProxyType(dict())) -> Callable:
#     """Customize JSON string decoder hooks.
# 
#     Object hook for typical deserialization scenarios.
# 
#     Notes
#     -----
#     Specifying a field in converters will ensure custom decoding/passthrough.
# 
#     Parameters
#     ----------
#     str_decoders: functions for decoding strings to objects.
#     extra_str_decoders: appends additional string decoders to str_decoders.
#     converters: field / parser function mapping.
#     """
# 
#     str_decoders = tuple(chain(str_decoders, extra_str_decoders))
#     object_hook = partial(json_decoder_hook, str_decoders=str_decoders,
#                           converters=converters)
# 
#     return object_hook


import json
import unittest
import iso8601
from datetime import datetime
from uuid import UUID
from foil.deserializers import make_json_decoder_hook
        serialized_data = json.dumps(
            {'time': '2017-01-19T21:41:18.056446Z',
             'date': '2013-04-05', 'date_str': '2013-04-05',
             'non_date': '8570', 'id': '060444c9-e2d7-4a55-964d-e495f2d5527f',
             'description': 'foo', 'data': {'count': 4},
             'foobar_field': 'foobar'}
        )
        converters = {'date_str': str}
        extra_decoders = (parse_foobar,)
        object_hook = make_json_decoder_hook(
            converters=converters, extra_str_decoders=extra_decoders
        )

        expected = {
            'time': datetime(2017, 1, 19, 21, 41, 18, 56446,
                             tzinfo=iso8601.UTC),
            'date': datetime(2013, 4, 5).date(),
            'date_str': '2013-04-05', 'non_date': '8570',
            'id': UUID('060444c9-e2d7-4a55-964d-e495f2d5527f', version=4),
            'description': 'foo', 'data': {'count': 4}, 'foobar_field': True
        }
        result = json.loads(serialized_data, object_hook=object_hook)

        self.assertEqual(expected, result)

    def test_nested_converters(self):
        serialized_data = json.dumps(
            {'time': {'date': '2014-04-01', 'time': '03:33:23'}}
        )
        converters = {'date': str}

# Path: foil/deserializers.py
# def make_json_decoder_hook(str_decoders=STRING_DECODERS,
#                            extra_str_decoders=tuple(),
#                            converters=MappingProxyType(dict())) -> Callable:
#     """Customize JSON string decoder hooks.
# 
#     Object hook for typical deserialization scenarios.
# 
#     Notes
#     -----
#     Specifying a field in converters will ensure custom decoding/passthrough.
# 
#     Parameters
#     ----------
#     str_decoders: functions for decoding strings to objects.
#     extra_str_decoders: appends additional string decoders to str_decoders.
#     converters: field / parser function mapping.
#     """
# 
#     str_decoders = tuple(chain(str_decoders, extra_str_decoders))
#     object_hook = partial(json_decoder_hook, str_decoders=str_decoders,
#                           converters=converters)
# 
#     return object_hook


# Path: tests/test_deserializers.py
import json
import unittest
import iso8601
from datetime import datetime
from uuid import UUID
from foil.deserializers import make_json_decoder_hook

        serialized_data = json.dumps(
            {'time': '2017-01-19T21:41:18.056446Z',
             'date': '2013-04-05', 'date_str': '2013-04-05',
             'non_date': '8570', 'id': '060444c9-e2d7-4a55-964d-e495f2d5527f',
             'description': 'foo', 'data': {'count': 4},
             'foobar_field': 'foobar'}
        )
        converters = {'date_str': str}
        extra_decoders = (parse_foobar,)
        object_hook = make_json_decoder_hook(
            converters=converters, extra_str_decoders=extra_decoders
        )

        expected = {
            'time': datetime(2017, 1, 19, 21, 41, 18, 56446,
                             tzinfo=iso8601.UTC),
            'date': datetime(2013, 4, 5).date(),
            'date_str': '2013-04-05', 'non_date': '8570',
            'id': UUID('060444c9-e2d7-4a55-964d-e495f2d5527f', version=4),
            'description': 'foo', 'data': {'count': 4}, 'foobar_field': True
        }
        result = json.loads(serialized_data, object_hook=object_hook)

        self.assertEqual(expected, result)

    def test_nested_converters(self):
        serialized_data = json.dumps(
            {'time': {'date': '2014-04-01', 'time': '03:33:23'}}
        )
        converters = {'date': str}

        object_hook = make_json_decoder_hook(converters=converters)