204件ヒット
[1-100件を表示]
(0.081秒)
種類
- インスタンスメソッド (84)
- モジュール関数 (72)
- 特異メソッド (24)
- 文書 (12)
- 関数 (12)
クラス
-
JSON
:: Parser (12) -
JSON
:: State (84) - Module (12)
モジュール
- JSON (72)
キーワード
- Ruby用語集 (12)
-
check
_ circular? (12) - depth (12)
- depth= (12)
- generate (12)
- load (12)
-
max
_ nesting (12) -
max
_ nesting= (12) - new (12)
- parse (12)
- parse! (12)
-
rb
_ mod _ nesting (12) - restore (12)
-
to
_ h (12) -
to
_ hash (12) - unparse (12)
検索結果
先頭5件
-
Module
. nesting -> [Class , Module] (18207.0) -
このメソッドを呼び出した時点でのクラス/モジュールのネスト情 報を配列に入れて返します。
...このメソッドを呼び出した時点でのクラス/モジュールのネスト情
報を配列に入れて返します。
//emlist[例][ruby]{
module Foo
module Bar
module Baz
p Module.nesting # => [Foo::Bar::Baz, Foo::Bar, Foo]
end
end
end
//}... -
JSON
:: State # max _ nesting -> Integer (12225.0) -
生成される JSON 形式の文字列のネストの深さの最大値を返します。
...state = JSON::State.new(max_nesting: 2)
json_state.max_nesting # => 2
JSON.generate([[]], json_state)
JSON.generate([[[]]], json_state) # => JSON::NestingError
//}
//emlist[例 ネストの深さチェックを行わない][ruby]{
require "json"
json_state = JSON::State.new(max_nesting:......0)
json_state.max_nesting # => 0
JSON.generate([[[[[[[[[[]]]]]]]]]], json_state)
//}... -
JSON
:: State # max _ nesting=(depth) (12225.0) -
生成される JSON 形式の文字列のネストの深さの最大値をセットします。
...せん。
//emlist[例][ruby]{
require "json"
json_state = JSON::State.new(max_nesting: 2)
json_state.max_nesting # => 2
JSON.generate([[]], json_state)
json_state.max_nesting = 3
json_state.max_nesting # => 3
JSON.generate([[[[]]]], json_state) # => JSON::NestingError
//}... -
JSON
. # generate(object , state = nil) -> String (6254.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...ます。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state JSON::State または、to_hash や to_h メ......: :space
a string that is put after, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a JSON array (default:......: :allow_nan
真を指定した場合、JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することを許すようになります。
偽を指定した場合、これらの値を生成しようとすると例外が発生します。
デフォルトは偽です。
: :max_nesting... -
JSON
:: State # to _ hash -> Hash (6206.0) -
自身をハッシュに変換します。
...equire "pp"
json_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,
# :buffer_initial_length=>1024}
//}... -
static VALUE rb
_ mod _ nesting(void) (6200.0) -
-
JSON
. # unparse(object , state = nil) -> String (6154.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...ます。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state JSON::State または、to_hash や to_h メ......: :space
a string that is put after, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a JSON array (default:......: :allow_nan
真を指定した場合、JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することを許すようになります。
偽を指定した場合、これらの値を生成しようとすると例外が発生します。
デフォルトは偽です。
: :max_nesting... -
JSON
:: State # check _ circular? -> bool (6148.0) -
循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。
...
a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s = JSON.state.new
begin
JSON.generate(a, s)
rescue JSON::NestingError => e
[e, s.ma......x_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)
json = JSON.generate(a, s2)
[json, s2.max_nesting, s2.check_circular?] # => ["[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[... -
JSON
. # load(source , proc = nil , options = {}) -> object (6136.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトとしてロードして返します。
...JSON
JSON.load(str) # => [1,2,3]
JSON.load(str, proc{|v| p v }) # => [1,2,3]
# 以下が表示される
# 1
# 2
# 3
# [1,2,3]
str=<<JSON
{ "a":1, "b":2, "c":3 }
JSON
JSON.load(str) # => {"a"=>1, "b"=>2, "c"=>3}
JSON.load(str, proc{|v| p v }) # => {"a"=>1, "b"=>2, "c"......# "a"
# 1
# "b"
# 2
# "c"
# 3
# {"a"=>1, "b"=>2, "c"=>3}
@param source JSON 形式の文字列を指定します。他には、to_str, to_io, read メソッドを持つオブジェクトも指定可能です。
@param proc Proc オブジェクトを指定します。
@param options......は以下の通りです。
: :max_nesting
入れ子になっているデータの最大の深さを指定します。
偽を指定すると深さのチェックを行いません。デフォルトは偽です。
: :allow_nan
真を指定した場合、JSON::NaN, JSON::Infinity,
JSON::Minus...