5件ヒット
[1-5件を表示]
(0.062秒)
種類
- モジュール関数 (4)
- インスタンスメソッド (1)
クラス
-
JSON
:: State (1)
モジュール
- JSON (4)
キーワード
-
check
_ circular? (1) - generate (1)
- load (1)
- restore (1)
- unparse (1)
検索結果
先頭5件
-
JSON
:: State # check _ circular? -> bool (18361.0) -
循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。
...y]{
require "json"
a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s = JSON.state.new
begin
JSON.generate(a, s)
rescue JSON::NestingErr......or => 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)
json = JSON.generate(a, s2)
[json, s2.max_nesting, s2.check_circular?] # => ["[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[... -
JSON
. # load(source , proc = nil , options = {}) -> object (18325.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトとしてロードして返します。
... JSON 形式の文字列を Ruby オブジェクトとしてロードして返します。
proc として手続きオブジェクトが与えられた場合は、読み込んだオブジェクトを
引数にその手続きを呼び出します。
require 'json'
str=<<JSON
[1,2,3]
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"=>3}......# 以下が表示される
# "a"
# 1
# "b"
# 2
# "c"
# 3
# {"a"=>1, "b"=>2, "c"=>3}
@param source JSON 形式の文字列を指定します。他には、to_str, to_io, read メソッドを持つオブジェクトも指定可能です。
@param proc Proc オブジェクトを指... -
JSON
. # restore(source , proc = nil , options = {}) -> object (9325.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトとしてロードして返します。
... JSON 形式の文字列を Ruby オブジェクトとしてロードして返します。
proc として手続きオブジェクトが与えられた場合は、読み込んだオブジェクトを
引数にその手続きを呼び出します。
require 'json'
str=<<JSON
[1,2,3]
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"=>3}......# 以下が表示される
# "a"
# 1
# "b"
# 2
# "c"
# 3
# {"a"=>1, "b"=>2, "c"=>3}
@param source JSON 形式の文字列を指定します。他には、to_str, to_io, read メソッドを持つオブジェクトも指定可能です。
@param proc Proc オブジェクトを指... -
JSON
. # generate(object , state = nil) -> String (325.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...オブジェクトを一行の JSON 形式の文字列に変換して返します。
デフォルトでは、サイズが最小となる JSON 形式の文字列を生成します。
また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成する......こともありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定で......tring 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: '')
: :check_circular
真を指定した場合、生成するオブジェクトの循環... -
JSON
. # unparse(object , state = nil) -> String (325.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...オブジェクトを一行の JSON 形式の文字列に変換して返します。
デフォルトでは、サイズが最小となる JSON 形式の文字列を生成します。
また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成する......こともありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定で......tring 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: '')
: :check_circular
真を指定した場合、生成するオブジェクトの循環...