22件ヒット
[1-22件を表示]
(0.064秒)
クラス
-
JSON
:: Parser (11) -
JSON
:: State (11)
キーワード
-
check
_ circular? (11) - source (11)
検索結果
-
JSON
:: Parser # source -> String (9203.0) -
現在のソースのコピーを返します。
...][ruby]{
require 'json'
parser = JSON::Parser.new(DATA.read)
print parser.source
# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# => "age":25
# => }
# => }
__END__
{
"Tanaka": {
"name":"tanaka",
"age":20......},
"Suzuki": {
"name":"suzuki",
"age":25
}
}
//}... -
JSON
:: State # check _ circular? -> bool (9103.0) -
循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。
...require "json"
a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s = JSON.state.new
begin
JSON.generate(a, s)
rescue JSON::NestingError =......> e
[e, s.max_nesting, s.check_circular?] # => [#<JSON::NestingError: nesting of 100 is too deep>, 100, true]
end
//}
//emlist[例 ネストをチェックしないケース][ruby]{
require "json"
a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[......]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s2 = JSON.state.new(max_nesting: 0)
json = JSON.generate(a, s2)
[json, s2.max_nesting, s2.check_circular?] # => ["[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...