Method: FlatFile::JSON.from_file
- Defined in:
- lib/flat_file/json.rb
.from_file(file) ⇒ Hash, ActiveSupport::HashWithIndifferentAccess
Return a hash parsed from a given JSON file.
10 11 12 13 14 15 16 |
# File 'lib/flat_file/json.rb', line 10 def self.from_file(file) data = ::JSON.parse(File.read(file)) if defined?(ActiveSupport::HashWithIndifferentAccess) return data&.with_indifferent_access || data end return data end |