Module: VCR::Cassette::Serializers::JSON
- Extended by:
- EncodingErrorHandling, JSON
- Included in:
- JSON
- Defined in:
- lib/vcr/cassette/serializers/json.rb
Overview
The JSON serializer. Uses ‘MultiJson` under the covers.
Constant Summary collapse
- ENCODING_ERRORS =
[MultiJson::DecodeError, ArgumentError]
Instance Method Summary collapse
-
#deserialize(string) ⇒ Hash
Deserializes the given string using ‘MultiJson`.
-
#file_extension ⇒ String
The file extension to use for this serializer.
-
#serialize(hash) ⇒ String
Serializes the given hash using ‘MultiJson`.
Methods included from EncodingErrorHandling
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given string using ‘MultiJson`.
40 41 42 43 44 |
# File 'lib/vcr/cassette/serializers/json.rb', line 40 def deserialize(string) handle_encoding_errors do MultiJson.decode(string) end end |
#file_extension ⇒ String
The file extension to use for this serializer.
22 23 24 |
# File 'lib/vcr/cassette/serializers/json.rb', line 22 def file_extension "json" end |
#serialize(hash) ⇒ String
Serializes the given hash using ‘MultiJson`.
30 31 32 33 34 |
# File 'lib/vcr/cassette/serializers/json.rb', line 30 def serialize(hash) handle_encoding_errors do MultiJson.encode(hash) end end |