mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
[flori/json] Add load_file
and load_file!
methods, with tests. Fixes issue #386.
0be363c99b
This commit is contained in:
parent
e1659af372
commit
c3614877d2
Notes:
git
2020-09-25 17:29:14 +09:00
2 changed files with 66 additions and 0 deletions
|
@ -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
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue