Commit graph

23 commits

Author SHA1 Message Date
Jean Boussier
8fe3fb5d5a [ruby/json] Stop caching the generator state pointer
Fix: https://github.com/ruby/json/issues/790

If we end up calling something that spills the state
on the heap, the pointer we received is outdated and
may be out of sync.

2ffa4ea46b
2025-04-30 08:12:41 +02:00
Jean Boussier
3bbb52f5c5 [ruby/json] Add missing assert_deprecated_warning
1b16a82980
2025-03-28 12:44:53 +09:00
Jean Boussier
e8c46f4ca5 [ruby/json] JSON.load invoke the proc callback directly from the parser.
And substitute the return value like `Marshal.load` doesm
which I can only assume was the intent.

This also open the door to re-implement all the `create_addition`
logic in `json/common.rb`.

73d2137fd3
2025-03-28 12:44:53 +09:00
Jean Boussier
f4529ecbe7 [ruby/json] Deprecate all *_default_options
Globally changing the behavior of the library is a bad idea, as
many different libraries may rely on `json` and may not expect it
and likely never tested that a different default config works for them.

If you need to change the behavior of JSON, it's best to do it only
locally, and not globally.

In addition the new `JSON::Coder` interface is much more suited for
that.

Another reason for the deprecation is that it's impossible to
make `JSON.load` and `JSON.dump` Ractor-safe with such API.

172762c6e4
2025-03-27 11:37:27 +09:00
Jean Boussier
ee0de3fd4e [ruby/json] JSON.dump: write directly into the provided IO
Ref: https://github.com/ruby/json/issues/524

Rather than to buffer everything in memory.

Unfortunately Ruby doesn't provide an API to write into
and IO without first allocating a string, which is a bit
wasteful.

f017af6c0a
2024-11-26 15:11:05 +09:00
Peter Zhu
64827b15e8 [ruby/json] Fix $VERBOSE restore
Manually sync this commit that was missed.

6ae9155
2024-11-11 15:13:24 -05:00
Jean Boussier
1b6a26e23a [ruby/json] JSON.load_file: explictly load the file as UTF-8
Fix: https://github.com/ruby/json/issues/697

This way even if `Encoding.default_external` is set to a weird value
the document will be parsed just fine.

3a8505a8fa
2024-11-11 09:40:11 +09:00
Jean Boussier
ca8f21ace8 [ruby/json] Resync 2024-11-05 18:00:36 +01:00
Étienne Barrié
82f7550f65 Use frozen string literals
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Jean Boussier
18cc663aef [ruby/json] Add test coverage for JSON.load with a Proc
Fix: https://github.com/ruby/json/issues/438

9dd89eaac8
2024-10-26 18:44:15 +09:00
YuheiNakasaka
57e1b64c81 [ruby/json] Fix behavior of trying to parse non-string objects
e2e9936047
2024-10-18 11:28:13 +09:00
tompng
70740deea7 [flori/json] Fix JSON.dump overload combination
41c2712a3b
2023-12-05 12:04:08 +09:00
Takashi Kokubun
96a809f621 Use require_relative in JSON tests
to prevent them from conflicting with yarp/test_helper
2023-08-25 15:32:14 -07:00
Kazuhiro NISHIYAMA
ce986b41ca
Remove unneeded begin and end 2020-09-30 15:55:07 +09:00
Kazuhiro NISHIYAMA
30bb040ea4
Fix Leaked tempfiles
20200930T033004Z.diff.html.gz
```
 [n/n] JSONCommonInterfaceTest#test_load = <elapsed> s
 [n/n] JSONCommonInterfaceTest#test_load_file = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file: #<Tempfile:<build-dir>/tmp/20200930-7601-ptnv6i (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file! = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file!: #<Tempfile:<build-dir>/tmp/20200930-7601-1la6m9 (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file_with_option = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file_with_option: #<Tempfile:<build-dir>/tmp/20200930-7601-blf9hz (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file_with_option! = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file_with_option!: #<Tempfile:<build-dir>/tmp/20200930-7601-b5gsdb (closed)>
```
2020-09-30 15:41:14 +09:00
Yusuke Endoh
e4b2c4fca5 t/json/json_common_interface_test.rb: fix wrong indentation
to prevent:

```
test/json/json_common_interface_test.rb:182: warning: mismatched indentations at 'end' with 'def' at 169
```
2020-09-25 23:37:12 +09:00
Hiroshi SHIBATA
6eeacbbc36
Extract assert assertion to assert_include and assert_not_include. 2020-09-25 20:28:31 +09:00
Hiroshi SHIBATA
81dc37b1b4 assert_true is not provided by test-unit 2020-09-25 17:28:42 +09:00
Keith Bennett
c3614877d2 [flori/json] Add load_file and load_file! methods, with tests. Fixes issue #386.
0be363c99b
2020-09-25 17:28:42 +09:00
Florian Frank
a4cf11c10f
[flori/json] fix test as reported in #343
565c72ba9e
2019-10-14 19:54:49 +09:00
Hiroshi SHIBATA
9eecd7a2fd
Ignore warnings about ambiguous first argument of regexp with assert match. 2019-06-01 14:44:24 +03:00
hsbt
bdda54c064 * test/json/json_common_interface_test.rb: use assert_raise instead of
assert_raises.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 13:27:08 +00:00
hsbt
a7b5d45466 * test/lib/test/unit.rb: added test files with _test suffix for json
upstream.
* test/json: merge original test files from json upstream.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 13:27:07 +00:00
Renamed from test/json/test_json_common_interface.rb (Browse further)