Module: VCR::Cassette::Serializers::JSON
- Extended by:
- EncodingErrorHandling, JSON, VCR::Cassette::SyntaxErrorHandling
- Included in:
- JSON
- Defined in:
- lib/vcr/cassette/serializers/json.rb
Overview
The JSON serializer.
Constant Summary collapse
- ENCODING_ERRORS =
[ArgumentError]
- SYNTAX_ERRORS =
[::JSON::ParserError]
Instance Method Summary collapse
-
#deserialize(string) ⇒ Hash
Deserializes the given string using ‘JSON`.
-
#file_extension ⇒ String
The file extension to use for this serializer.
-
#serialize(hash) ⇒ String
Serializes the given hash using ‘JSON`.
Methods included from EncodingErrorHandling
Methods included from VCR::Cassette::SyntaxErrorHandling
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given string using ‘JSON`.
44 45 46 47 48 49 50 |
# File 'lib/vcr/cassette/serializers/json.rb', line 44 def deserialize(string) handle_encoding_errors do handle_syntax_errors do ::JSON.parse(string) end end end |
#file_extension ⇒ String
The file extension to use for this serializer.
26 27 28 |
# File 'lib/vcr/cassette/serializers/json.rb', line 26 def file_extension "json" end |
#serialize(hash) ⇒ String
Serializes the given hash using ‘JSON`.
34 35 36 37 38 |
# File 'lib/vcr/cassette/serializers/json.rb', line 34 def serialize(hash) handle_encoding_errors do ::JSON.pretty_generate(hash) end end |