diff options
Diffstat (limited to 'lib/json/common.rb')
-rw-r--r-- | lib/json/common.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb index 991d760..bd33997 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -282,6 +282,16 @@ module JSON Parser.new(source, **(opts||{})).parse end + # Parses the content of a file (see parse method documentation for more information). + def load_file(filespec, opts = {}) + parse(File.read(filespec), opts) + end + + # Parses the content of a file (see parse! method documentation for more information). + def load_file!(filespec, opts = {}) + parse!(File.read(filespec), opts) + end + # :call-seq: # JSON.generate(obj, opts = nil) -> new_string # |