Class: ParsingUtils::JSONParser

Inherits:
Object
  • Object
show all
Defined in:
lib/parsing_utils.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.supported_mime_typesObject

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_typeObject



37
38
39
# File 'lib/parsing_utils.rb', line 37

def default_mime_type
  'application/json'
end

.dependenciesObject



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, options = {})
  options = options.dup
  case options.delete(:format)
  when :pretty
    JSON.pretty_generate object, options
  else
    JSON.generate(object, options)
  end
end

.load(object, options = {}) ⇒ Object



49
50
51
# File 'lib/parsing_utils.rb', line 49

def load(object, options = {})
  JSON.parse(object, options)
end