Class: Crack::JSON
- Inherits:
-
Object
- Object
- Crack::JSON
- Defined in:
- lib/crack/json.rb
Class Method Summary collapse
Class Method Details
.parse(json) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/crack/json.rb', line 14 def self.parse(json) yaml = unescape(convert_json_to_yaml(json)) YAML.safe_load(yaml, [Regexp, Date, Time]) rescue *parser_exceptions raise ParseError, "Invalid JSON string" rescue Psych::DisallowedClass yaml end |
.parser_exceptions ⇒ Object
10 11 12 |
# File 'lib/crack/json.rb', line 10 def self.parser_exceptions @parser_exceptions ||= [ArgumentError, Psych::SyntaxError] end |