summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/lib/json/common.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 8e45b511fc..bf2c599d0d 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/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
#