Module: Midnight::Utilities::JsonSerializer
- Defined in:
- lib/midnight/utilities/json_serializer.rb
Class Method Summary collapse
Class Method Details
.dump(hash) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/midnight/utilities/json_serializer.rb', line 7 module_function def dump(hash) hash = hash.try(:to_hash) || hash ::JSON.dump(hash) rescue ::TypeError hash end |
.load(string) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/midnight/utilities/json_serializer.rb', line 14 module_function def load(string) hash = ::JSON.load(string) hash.try(:to_hash).try(:deep_symbolize_keys) || hash rescue ::TypeError string end |