るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
47件ヒット [1-47件を表示] (0.040秒)
トップページ > クエリ:json[x] > クエリ:state[x] > バージョン:2.4.0[x]

別のキーワード

  1. json to_json
  2. json parser
  3. json parse
  4. json []

検索結果

JSON.state -> JSON::Ext::Generator::State (106048.0)

JSON ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。

JSON ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。

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

JSON.state # => JSON::Ext::Generator::State
//}

JSON::State.from_state(options) -> JSON::State (61654.0)

与えられた options によって生成した JSON::State のインスタンスを返します。

与えられた options によって生成した JSON::State のインスタンスを返します。

@param options JSON::State のインスタンスか、ハッシュを指定します。

@return options がハッシュである場合は、それによって初期化した JSON::State を
返します。options が JSON::State のインスタンスである場合は単に
options を返します。いずれでも無い場合は、何も設定されていない JSON::State の
インスタンスを返します。

//emlist[例 Hash...

JSON.#generate(object, state = nil) -> String (51895.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

デフォルトでは、サイズが最小となる JSON 形式の文字列を生成します。
また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
...

JSON.#unparse(object, state = nil) -> String (51895.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

デフォルトでは、サイズが最小となる JSON 形式の文字列を生成します。
また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
...

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (51853.0)

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

このメソッドはあるオブジェクトに to_json メソッドが定義されていない場合に使用する
フォールバックのためのメソッドです。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

//emlist[例][ruby...

絞り込み条件を変える

JSON::Generator::GeneratorMethods::String#to_json(state_or_hash = nil) -> String (51853.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

自身のエンコードは UTF-8 であるべきです。
"\u????" のように UTF-16 ビッグエンディアンでエンコードされた文字列を返すことがあります。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

//emlist[例][ruby]...

JSON::Generator::GeneratorMethods::Array#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

[1, 2, 3].to_json # => "[1,2,3]"
//}

JSON::Generator::GeneratorMethods::FalseClass#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

"false" という文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

false.to_json # => "false"
//}

JSON::Generator::GeneratorMethods::Float#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

(1.0).to_json # => "1.0"
//}

JSON::Generator::GeneratorMethods::Hash#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

person = { "name" => "tanaka", "age" => 19 }
person.to_json # ...

絞り込み条件を変える

JSON::Generator::GeneratorMethods::Integer#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

10.to_json # => "10"
//}

JSON::Generator::GeneratorMethods::NilClass#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

"null" という文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

nil.to_json # => "null"
//}

JSON::Generator::GeneratorMethods::TrueClass#to_json(state_or_hash = nil) -> String (51799.0)

自身から生成した JSON 形式の文字列を返します。

自身から生成した JSON 形式の文字列を返します。

"true" という文字列を返します。

@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

true.to_json # => "true"
//}

JSON.#pretty_generate(object, options = nil) -> String (51229.0)

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。

pretty_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param options JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。

//emlist[...

JSON.#pretty_unparse(object, options = nil) -> String (51229.0)

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。

pretty_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param options JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。

//emlist[...

絞り込み条件を変える

JSON::Ext::Generator::State (51097.0)

Alias of JSON::State

Alias of JSON::State

JSON::State (51097.0)

Ruby オブジェクトから JSON 形式の文字列を生成する間、 JSON 形式の文字列を生成するための設定を保持しておくために使用するクラスです。

Ruby オブジェクトから JSON 形式の文字列を生成する間、
JSON 形式の文字列を生成するための設定を保持しておくために使用するクラスです。

JSON::State.new(options = {}) -> JSON::State (43183.0)

自身を初期化します。

自身を初期化します。

@param options ハッシュを指定します。
指定可能なオプションは以下の通りです。

: :indent
インデントに使用する文字列を指定します。デフォルトは空文字列です。
: :space
JSON 形式の文字列のトークン間に挿入する文字列を指定します。デフォルトは空文字列です。
: :space_before
JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列をセットします。デフォルトは空文字列です。
: :object_nl
JSON 形式の文字列中に現れる...

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

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

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

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

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

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

...

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

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

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

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

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

json_state = JSON:...

絞り込み条件を変える

JSON::State#space -> String (42391.0)

JSON 形式の文字列のトークン間に挿入する文字列を返します。

JSON 形式の文字列のトークン間に挿入する文字列を返します。

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

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

json_state = JSON::State.new(space: "\t")
json_...

JSON::State#space_before -> String (42391.0)

JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の 前に挿入する文字列を返します。

JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列を返します。

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

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

js...

JSON::State#configure(options = {}) -> self (42379.0)

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

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

オプションで使用するハッシュのキーについては JSON::State.new を参照してください。

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

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

json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{\t\"key1\...

JSON::State#merge(options = {}) -> self (42379.0)

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

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

オプションで使用するハッシュのキーについては JSON::State.new を参照してください。

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

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

json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{\t\"key1\...

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

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

生成される 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.g...

絞り込み条件を変える

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

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

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

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

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

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

JSON::State#space=(string) (42373.0)

JSON 形式の文字列のトークン間に挿入する文字列をセットします。

JSON 形式の文字列のトークン間に挿入する文字列をセットします。

@param string JSON 形式の文字列のトークン間に挿入する文字列を指定します。

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

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

JSON::State#space_before=(string) (42373.0)

JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の 前に挿入する文字列をセットします。

JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列をセットします。

@param string JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列をセットします。

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

json_state = JSON::State.new(space_before: "")
json_state.space_before # => ""
puts JSON.gen...

JSON::State#array_nl -> String (42283.0)

JSON の配列の後に出力する文字列を返します。

JSON の配列の後に出力する文字列を返します。

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

json_state = JSON::State.new({})
json_state.array_nl # => ""
json_state = JSON::State.new(array_nl: "\n")
json_state.array_nl # => "\n"
//}

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

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

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

@param string インデントに使用する文字列を指定します。

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

json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"
json_state.indent = "...

絞り込み条件を変える

JSON::State#array_nl=(str) (42247.0)

JSON の配列の後に出力する文字列をセットします。

JSON の配列の後に出力する文字列をセットします。

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

json_state = JSON::State.new({})
json_state.array_nl # => ""
json_state.array_nl = "\n"
json_state.array_nl # => "\n"
//}

JSON::State#allow_nan? -> bool (42235.0)

NaN, Infinity, -Infinity を生成できる場合、真を返します。 そうでない場合は偽を返します。

NaN, Infinity, -Infinity を生成できる場合、真を返します。
そうでない場合は偽を返します。

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

json_state = JSON::State.new({})
json_state.allow_nan? # => false
json_state = JSON::State.new(allow_nan: true)
json_state.allow_nan? # => true
//}

@see 4627

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

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

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

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

a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]...

JSON::State#indent -> String (42181.0)

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

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

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

json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"
//}

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

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

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

//emlist[例][ruby]{
require "json"
require "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,
# ...

絞り込み条件を変える

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

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

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

//emlist[例][ruby]{
require "json"
require "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,
# ...

JSON::State#generate(obj) -> String (42097.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.

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.

JSON::State#ascii_only? -> bool (42049.0)

ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。 そうでない場合に偽を返します。

ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。
そうでない場合に偽を返します。

JSON::State#depth=(depth) (42049.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
JSON to the integer depth, max_nesting = 0 if no maximum should be
checked.

JSON::State#[](name) -> object (42001.0)

Return the value returned by method name.

Return the value returned by method name.

絞り込み条件を変える

JSON::State#[]=(name, value) (42001.0)

Set the attribute name to value.

Set the attribute name to value.

JSON::State#buffer_initial_length -> Integer (42001.0)

This integer returns the current initial length of the buffer.

This integer returns the current initial length of the buffer.

JSON::State#buffer_initial_length=(length) (42001.0)

This sets the initial length of the buffer to length, if length > 0, otherwise its value isn't changed.

This sets the initial length of the buffer to length, if length > 0,
otherwise its value isn't changed.

JSON::State#depth -> Integer (42001.0)

This integer returns the current depth of data structure nesting.

This integer returns the current depth of data structure nesting.

JSON::State#quirks_mode -> bool (42001.0)

Returns true, if quirks mode is enabled. Otherwise returns false.

Returns true, if quirks mode is enabled. Otherwise returns false.

絞り込み条件を変える

JSON::State#quirks_mode=(enable) (42001.0)

If set to true, enables the quirks_mode mode.

If set to true, enables the quirks_mode mode.

JSON::State#quirks_mode? -> bool (42001.0)

Returns true, if quirks mode is enabled. Otherwise returns false.

Returns true, if quirks mode is enabled. Otherwise returns false.