-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to investigate JSON.load and JSON.parse
According to rurema/doctree/issues/2646, `JSON.load` calls `JSON.parse` internally. But I'm not sure it is true. This script investigate the behaviour then I learned it is true.
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'json' | ||
require 'trace_location' | ||
|
||
TraceLocation.trace(format: :log) do | ||
JSON.load('{"foo": 42}') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Logged by TraceLocation gem at 2022-01-16 01:47:21 +0900 | ||
https://github.com/yhirano55/trace_location | ||
|
||
[Tracing events] C: Call, R: Return | ||
|
||
C /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:557 [JSON.load] | ||
C /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:215 [JSON.parse] | ||
C /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:126 [JSON.create_id] | ||
R /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:128 [JSON.create_id] | ||
R /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:217 [JSON.parse] | ||
R /home/pocke/.rbenv/versions/trunk/lib/ruby/3.2.0/json/common.rb:572 [JSON.load] | ||
|
||
Result: {"foo"=>42} |