Class: Crack::JSON
- Inherits:
-
Object
- Object
- Crack::JSON
- Defined in:
- lib/crack/json.rb
Class Method Summary collapse
-
.parse(json) ⇒ Object
Ruby < 2.6.
- .parser_exceptions ⇒ Object
Class Method Details
.parse(json) ⇒ Object
Ruby < 2.6
25 26 27 28 29 30 31 32 |
# File 'lib/crack/json.rb', line 25 def self.parse(json) yaml = unescape(convert_json_to_yaml(json)) YAML.safe_load(yaml, permitted_classes: [Regexp, Date, Time]) rescue *parser_exceptions raise ParseError, "Invalid JSON string" rescue Psych::DisallowedClass yaml end |
.parser_exceptions ⇒ Object
11 12 13 |
# File 'lib/crack/json.rb', line 11 def self.parser_exceptions @parser_exceptions ||= [ArgumentError, Psych::SyntaxError] end |