Class: MuckEngine::JsonParser
- Inherits:
-
Object
- Object
- MuckEngine::JsonParser
- Defined in:
- lib/muck-engine/json.rb
Class Method Summary collapse
-
.json_parse(data) ⇒ Object
The various json parsers can choke on various json so try them all.
- .try_active_json(data) ⇒ Object
- .try_crack(data) ⇒ Object
- .try_json(data) ⇒ Object
Class Method Details
.json_parse(data) ⇒ Object
The various json parsers can choke on various json so try them all
5 6 7 |
# File 'lib/muck-engine/json.rb', line 5 def self.json_parse(data) try_crack(data) || try_json(data) || try_active_json(data) end |
.try_active_json(data) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/muck-engine/json.rb', line 23 def self.try_active_json(data) ActiveSupport::JSON.decode(data) rescue => ex #puts ex nil end |
.try_crack(data) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/muck-engine/json.rb', line 9 def self.try_crack(data) Crack::JSON.parse(data) rescue => ex #puts ex nil end |
.try_json(data) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/muck-engine/json.rb', line 16 def self.try_json(data) JSON.parse(data) rescue => ex #puts ex nil end |