るりまサーチ

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

別のキーワード

  1. encoding windows_31j
  2. _builtin windows_31j
  3. _builtin cswindows31j
  4. encoding cswindows31j
  5. json j

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 > >>

JSON::State#generate(obj) -> String (21202.0)

Generates a valid JSON document from object obj and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception.

...
Generate
s a valid JSON document from object obj and returns the
result. If no valid JSON document can be created this method raises a
GeneratorError exception....

RDoc::Generator::JsonIndex#generate -> () (21102.0)

解析した情報を RDoc::Generator::JsonIndex::SEARCH_INDEX_FILE に出 力します。

...解析した情報を RDoc::Generator::JsonIndex::SEARCH_INDEX_FILE に出
力します。...

Kernel#JSON(object, options = {}) -> object (6119.0)

第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。

...クトか JSON 形式の文字列を返します。

第一引数に文字列のようなオブジェクトを指定した場合は、それを JSON.#parse を用いてパースした結果を返します。
そうでないオブジェクトを指定した場合は、それを JSON.#generate を用...
...

@param object 任意のオブジェクトを指定します。

@param options JSON.#parse, JSON.#generate に渡すオプションを指定します。

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

J
SON('[1,2,{"name":"tanaka","age":19}]')
# => [1, 2, {"name"=>"tanaka", "age"=>19}]

J
SON('[1,2,{"name":...
..."tanaka","age":19}]', symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}]
//}

@see JSON.#parse, JSON.#generate...

JSON::State#object_nl -> String (6113.0)

JSON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列を返します。

...
J
SON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列を返します。

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

j
son_state = JSON::State.new(object_nl: "")
j
son_state.object_nl # => ""
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }...
...], json_state)
# => [1,2,{"name":"tanaka","age":19}]

j
son_state = JSON::State.new(object_nl: "\n")
j
son_state.object_nl # => "\n"
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)

# => [1,2,{
# "name":"tanaka",
# "age":19
# }]
//}...

JSON::State#object_nl=(string) (6113.0)

JSON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列をセットします。

...
J
SON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列をセットします。

@param string JSON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列を指定します。

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

j
son_state = JSON::State.new(object_nl: "")
j
son_state.object_nl # => ""
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => [1,2,{"name":"tanaka","age":19}]

j
son_state.object_nl = "\n"
j
son_state.object_nl # => "\n"
puts JSON.generate([1, 2, {...
...name: "tanaka", age: 19 }], json_state)
# => [1,2,{
# "name":"tanaka",
# "age":19
# }]
//}...

絞り込み条件を変える

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

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

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

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

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

j
son_state = JSON::State.new(max_nesting: 2)
j
so...
...# => 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
SON.generate([[[[[[[[[[...
...]]]]]]]]]], json_state)
//}...

JSON::State#check_circular? -> bool (3013.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#configure(options = {}) -> self (3013.0)

与えられたハッシュで自身を設定します。

...については JSON::State.new を参照してください。

@param options このオブジェクトの設定をするためのハッシュを指定します。

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

j
son_state = JSON::State.new(indent: "\t")
j
son_state.indent # => "\t"
J
SON.generate({key1: "value...
...1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"

j
son_state.configure(indent: " ")
j
son_state.indent # => " "
J
SON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{ \"key1\":\"value1\", \"key2\":\"value2\"}"
//}

@see JSON::State.new...

JSON::State#indent=(string) (3013.0)

インデントに使用する文字列をセットします。

...][ruby]{
require "json"

j
son_state = JSON::State.new(indent: "\t")
j
son_state.indent # => "\t"
J
SON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"
j
son_state.indent = " "
J
SON.generate({key1: "value1", key2: "value2"}, json_state)
# => "...
<< 1 2 > >>