mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
21 lines
537 B
Python
21 lines
537 B
Python
try:
|
|
import simplejson as json
|
|
except ImportError:
|
|
import json
|
|
|
|
|
|
def deserialize(cassette_string):
|
|
return json.loads(cassette_string)
|
|
|
|
|
|
def serialize(cassette_dict):
|
|
try:
|
|
return json.dumps(cassette_dict, indent=4)
|
|
except UnicodeDecodeError:
|
|
raise UnicodeDecodeError(
|
|
"Error serializing cassette to JSON. ",
|
|
"Does this HTTP interaction contain binary data? ",
|
|
"If so, use a different serializer (like the yaml serializer) ",
|
|
"for this request"
|
|
)
|