mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
12 lines
No EOL
363 B
Ruby
12 lines
No EOL
363 B
Ruby
class JSONWithIndifferentAccess
|
|
def self.load(json)
|
|
ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(json || '{}'))
|
|
rescue JSON::ParserError
|
|
Rails.logger.error "Unparsable JSON in JSONWithIndifferentAccess: #{json}"
|
|
{ 'error' => 'unparsable json detected during de-serialization' }
|
|
end
|
|
|
|
def self.dump(hash)
|
|
JSON.dump(hash)
|
|
end
|
|
end |