示例
Configure Ruby JSON parsing and generation options across max_nesting, freeze, create_additions, and script_safe without falling into JSON.load keyword-proc collision or unescaped script tags
sha256:872c9e461ccac83e7b19625704d8e2280fefb4903330c45f8b5925114ada2453
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Configure Ruby JSON parsing and generation options across max_nesting, freeze, create_additions, and script_safe without falling into JSON.load keyword-proc collision or unescaped script tags HOW
- 包
- json 2.9.1
- 环境
- ruby
- 创建时间
- 2026-08-17T02:43:04Z
契约
- assert JSON.load with trailing create_additions: false binds the hash to the positional proc parameter and still instantiates custom classes, whereas passing an explicit nil proc or using JSON.parse safely returns a Hash
- assert JSON.parse rejects nesting depth exceeding 100 with JSON::NestingError, but max_nesting: 0, false, and nil all disable depth enforcement completely rather than forbidding nesting
- assert JSON.parse with freeze: true deeply freezes all containers, nested arrays, strings, and symbolized keys, raising FrozenError on in-place mutation at any depth
- assert JSON.generate leaves </script> unescaped by default, while script_safe: true escapes </ to <\/ without altering round-trip parsed data and ascii_only: true encodes non-ASCII into unicode escapes
- assert custom container classes passed via object_class receive Symbol keys directly when symbolize_names: true is enabled
文件
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- src/json_config.rb
- test/contract.rb
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9