るりまサーチ

最速Rubyリファレンスマニュアル検索!
72件ヒット [1-72件を表示] (0.077秒)

別のキーワード

  1. _builtin max
  2. enumerable max
  3. _builtin max_by
  4. enumerable max_by
  5. range max

ライブラリ

クラス

キーワード

検索結果

JSON::State#max_nesting -> Integer (21126.0)

生成される JSON 形式の文字列のネストの深さの最大値を返します。

... JSON 形式の文字列のネストの深さの最大値を返します。

この値がゼロである場合は、ネストの深さのチェックを行いません。

//emlist[例 ネストの深さチェックを行う][ruby]{
require "json"

j
son_state = JSON::State.new(max_nesting: 2)
j
so...
...te.max_nesting # => 2
J
SON.generate([[]], json_state)
J
SON.generate([[[]]], json_state) # => JSON::NestingError
//}

//emlist[例 ネストの深さチェックを行わない][ruby]{
require "json"

j
son_state = JSON::State.new(max_nesting: 0)
j
son_state.max_nesting # => 0
J
SO...
...N.generate([[[[[[[[[[]]]]]]]]]], json_state)
//}...

JSON::State#max_nesting=(depth) (9126.0)

生成される JSON 形式の文字列のネストの深さの最大値をセットします。

...れる JSON 形式の文字列のネストの深さの最大値をセットします。

この値にゼロをセットすると、ネストの深さのチェックを行いません。

//emlist[例][ruby]{
require "json"

j
son_state = JSON::State.new(max_nesting: 2)
j
son_state.max_nesting...
...# => 2
J
SON.generate([[]], json_state)
j
son_state.max_nesting = 3
j
son_state.max_nesting # => 3
J
SON.generate([[[[]]]], json_state) # => JSON::NestingError
//}...

JSON::State#check_circular? -> bool (3019.0)

循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。

...by]{
require "json"

a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s = JSON.state.new
begin
J
SON.generate(a, s)
rescue JSON::NestingEr...
...ror => e
[e, s.max_nesting, s.check_circular?] # => [#<JSON::NestingError: nesting of 100 is too deep>, 100, true]
end
//}

//emlist[例 ネストをチェックしないケース][ruby]{
require "json"

a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...
...[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s2 = JSON.state.new(max_nesting: 0)
j
son = JSON.generate(a, s2)
[json, s2.max_nesting, s2.check_circular?] # => ["[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...

JSON::State#depth=(depth) (3017.0)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

...This sets the maximum level of data structure nesting in the generated
J
SON to the integer depth, max_nesting = 0 if no maximum should be
checked....

JSON::State#to_h -> Hash (3007.0)

自身をハッシュに変換します。

.../emlist[例][ruby]{
require "json"
require "pp"

j
son_state = JSON::State.new
pp json_state.to_h

# => {:indent=>"",
# :space=>"",
# :space_before=>"",
# :object_nl=>"",
# :array_nl=>"",
# :allow_nan=>false,
# :ascii_only=>false,
# :max_nesting=>100,
# :depth=>0,
#...

絞り込み条件を変える

JSON::State#to_hash -> Hash (3007.0)

自身をハッシュに変換します。

.../emlist[例][ruby]{
require "json"
require "pp"

j
son_state = JSON::State.new
pp json_state.to_h

# => {:indent=>"",
# :space=>"",
# :space_before=>"",
# :object_nl=>"",
# :array_nl=>"",
# :allow_nan=>false,
# :ascii_only=>false,
# :max_nesting=>100,
# :depth=>0,
#...