Class: ParsingUtils::JSONParser
- Inherits:
-
Object
- Object
- ParsingUtils::JSONParser
- Defined in:
- lib/parsing_utils.rb
Class Attribute Summary collapse
-
.supported_mime_types ⇒ Object
Returns the value of attribute supported_mime_types.
Class Method Summary collapse
- .default_mime_type ⇒ Object
- .dependencies ⇒ Object
- .dump(object, options = {}) ⇒ Object
- .load(object, options = {}) ⇒ Object
Class Attribute Details
.supported_mime_types ⇒ Object
Returns the value of attribute supported_mime_types.
33 34 35 |
# File 'lib/parsing_utils.rb', line 33 def supported_mime_types @supported_mime_types end |
Class Method Details
.default_mime_type ⇒ Object
37 38 39 |
# File 'lib/parsing_utils.rb', line 37 def default_mime_type 'application/json' end |
.dependencies ⇒ Object
34 35 36 |
# File 'lib/parsing_utils.rb', line 34 def dependencies require 'json' end |
.dump(object, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/parsing_utils.rb', line 40 def dump(object, = {}) = .dup case .delete(:format) when :pretty JSON.pretty_generate object, else JSON.generate(object, ) end end |
.load(object, options = {}) ⇒ Object
49 50 51 |
# File 'lib/parsing_utils.rb', line 49 def load(object, = {}) JSON.parse(object, ) end |