Class: Crack::JSON
- Inherits:
-
Object
- Object
- Crack::JSON
- Defined in:
- lib/crack/json.rb
Class Method Summary collapse
Class Method Details
.parse(json) ⇒ Object
25 26 27 28 29 |
# File 'lib/crack/json.rb', line 25 def self.parse(json) YAML.load(unescape(convert_json_to_yaml(json))) rescue *parser_exceptions raise ParseError, "Invalid JSON string" end |
.parser_exceptions ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/crack/json.rb', line 11 def self.parser_exceptions @parser_exceptions ||= begin exceptions = [ArgumentError] if const_defined?(:Psych) if Psych.const_defined?(:SyntaxError) exceptions << Psych::SyntaxError end end exceptions end end |