in cassette/utils.py [0:0]
def json_str_decode_dict(data):
"""Decode the dictionary portion of a JSON blob as a string.
This helper function is necessary to decode the data as an ASCII string
instead of a unicode string, which is required in order to be consumed
by the mock HTTP response.
"""
# Original code is from stackoverflow:
# http://stackoverflow.com/questions/956867/how-to-get-string-objects-i
# nstead-of-unicode-ones-from-json-in-python
rv = {}
for key, value in data.iteritems():
if isinstance(key, unicode):
key = key.encode(TEXT_ENCODING)
if isinstance(value, unicode):
value = value.encode(TEXT_ENCODING)
elif isinstance(value, list):
value = JsonEncoder.json_str_decode_list(value)
elif isinstance(value, dict):
value = JsonEncoder.json_str_decode_dict(value)
rv[key] = value
return rv