@@ -298,12 +298,12 @@ def inside(chars, delim, type)
298
298
# Certain versions of Ruby and of the pure_json gem not support loading
299
299
# scalar JSON values, such a numbers, booleans, strings, etc. These
300
300
# simple values must be first wrapped inside a JSON object before calling
301
- # `JSON.load `.
301
+ # `JSON.parse `.
302
302
#
303
303
# # works in most JSON versions, raises in some versions
304
- # JSON.load ("true")
305
- # JSON.load ("123")
306
- # JSON.load ("\"abc\"")
304
+ # JSON.parse ("true")
305
+ # JSON.parse ("123")
306
+ # JSON.parse ("\"abc\"")
307
307
#
308
308
# This is an known issue for:
309
309
#
@@ -317,12 +317,12 @@ def inside(chars, delim, type)
317
317
# causes issues in environments that cannot compile the gem. We previously
318
318
# had a direct dependency on `json_pure`, but this broke with the v2 update.
319
319
#
320
- # This method allows us to detect how the `JSON.load ` behaves so we know
320
+ # This method allows us to detect how the `JSON.parse ` behaves so we know
321
321
# if we have to wrap scalar JSON values to parse them or not.
322
322
# @api private
323
323
def self . requires_wrapping?
324
324
begin
325
- JSON . load ( 'false' )
325
+ JSON . parse ( 'false' )
326
326
rescue JSON ::ParserError
327
327
true
328
328
end
@@ -332,12 +332,12 @@ def self.requires_wrapping?
332
332
def parse_json ( token , quoted = false )
333
333
begin
334
334
if quoted
335
- token . value = JSON . load ( "{\" value\" :#{ token . value } }" ) [ 'value' ]
335
+ token . value = JSON . parse ( "{\" value\" :#{ token . value } }" ) [ 'value' ]
336
336
else
337
337
begin
338
- token . value = JSON . load ( "{\" value\" :#{ token . value } }" ) [ 'value' ]
338
+ token . value = JSON . parse ( "{\" value\" :#{ token . value } }" ) [ 'value' ]
339
339
rescue
340
- token . value = JSON . load ( sprintf ( '{"value":"%s"}' , token . value . lstrip ) ) [ 'value' ]
340
+ token . value = JSON . parse ( sprintf ( '{"value":"%s"}' , token . value . lstrip ) ) [ 'value' ]
341
341
end
342
342
end
343
343
rescue JSON ::ParserError
@@ -349,9 +349,9 @@ def parse_json(token, quoted = false)
349
349
def parse_json ( token , quoted = false )
350
350
begin
351
351
if quoted
352
- token . value = JSON . load ( token . value )
352
+ token . value = JSON . parse ( token . value )
353
353
else
354
- token . value = JSON . load ( token . value ) rescue JSON . load ( sprintf ( '"%s"' , token . value . lstrip ) )
354
+ token . value = JSON . parse ( token . value ) rescue JSON . parse ( sprintf ( '"%s"' , token . value . lstrip ) )
355
355
end
356
356
rescue JSON ::ParserError
357
357
token . type = T_UNKNOWN
0 commit comments