別のキーワード
種類
- インスタンスメソッド (38)
- モジュール関数 (4)
- 特異メソッド (3)
- クラス (2)
クラス
-
JSON
:: State (31)
モジュール
- JSON (5)
-
JSON
:: Generator :: GeneratorMethods :: Array (1) -
JSON
:: Generator :: GeneratorMethods :: FalseClass (1) -
JSON
:: Generator :: GeneratorMethods :: Float (1) -
JSON
:: Generator :: GeneratorMethods :: Hash (1) -
JSON
:: Generator :: GeneratorMethods :: Integer (1) -
JSON
:: Generator :: GeneratorMethods :: NilClass (1) -
JSON
:: Generator :: GeneratorMethods :: Object (1) -
JSON
:: Generator :: GeneratorMethods :: String (1) -
JSON
:: Generator :: GeneratorMethods :: TrueClass (1)
キーワード
- State (2)
- [] (1)
- []= (1)
-
allow
_ nan? (1) -
array
_ nl (1) -
array
_ nl= (1) -
ascii
_ only? (1) -
buffer
_ initial _ length (1) -
buffer
_ initial _ length= (1) -
check
_ circular? (1) - configure (1)
- depth (1)
- depth= (1)
-
from
_ state (1) - generate (2)
- indent (1)
- indent= (1)
-
max
_ nesting (1) -
max
_ nesting= (1) - merge (1)
- new (1)
-
object
_ nl (1) -
object
_ nl= (1) -
pretty
_ generate (1) -
pretty
_ unparse (1) -
quirks
_ mode (1) -
quirks
_ mode= (1) -
quirks
_ mode? (1) - space (1)
- space= (1)
-
space
_ before (1) -
space
_ before= (1) -
to
_ h (1) -
to
_ hash (1) -
to
_ json (9) - unparse (1)
検索結果
先頭5件
-
JSON
. state -> JSON :: Ext :: Generator :: State (106054.0) -
JSON ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。
...
JSON ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。
//emlist[例][ruby]{
require "json"
JSON.state # => JSON::Ext::Generator::State
//}... -
JSON
:: State . from _ state(options) -> JSON :: State (61660.0) -
与えられた options によって生成した JSON::State のインスタンスを返します。
...した JSON::State のインスタンスを返します。
@param options JSON::State のインスタンスか、ハッシュを指定します。
@return options がハッシュである場合は、それによって初期化した JSON::State を
返します。options が JSON::State......れていない JSON::State の
インスタンスを返します。
//emlist[例 Hash を指定][ruby]{
require "json"
json_state = JSON::State.from_state(indent: "\t")
json_state.class # => JSON::Ext::Generator::State
json_state.indent # => "\t"
//}
//emlist[例 JSON::State を指定][......ruby]{
require "json"
json_state = JSON::State.from_state(indent: "\t")
# JSON を出力する何らかの処理を実行する
copy = JSON::State.from_state(json_state)
copy.class # => JSON::Ext::Generator::State
copy.indent # => "\t"
//}... -
JSON
. # generate(object , state = nil) -> String (51901.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 (51901.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
:: Generator :: GeneratorMethods :: Object # to _ json(state _ or _ hash = nil) -> String (51859.0) -
自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。
...した結果を JSON 形式の文字列に変換して返します。
このメソッドはあるオブジェクトに to_json メソッドが定義されていない場合に使用する
フォールバックのためのメソッドです。
@param state_or_hash 生成する JSON 形式の文字......をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
class Person
attr :name, :age
def initialize(name, ag......e)
@name, @age = name, age
end
end
tanaka = Person.new("tanaka", 29)
tanaka.to_json # => "\"#<Person:0x00007ffdec0167c8>\""
tanaka.method(:to_json).owner # => JSON::Ext::Generator::GeneratorMethods::Object
//}... -
JSON
:: Generator :: GeneratorMethods :: String # to _ json(state _ or _ hash = nil) -> String (51859.0) -
自身から生成した JSON 形式の文字列を返します。
...ら生成した JSON 形式の文字列を返します。
自身のエンコードは UTF-8 であるべきです。
"\u????" のように UTF-16 ビッグエンディアンでエンコードされた文字列を返すことがあります。
@param state_or_hash 生成する JSON 形式の文字......に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
puts "test".to_json # => "test"
puts '"'.to_json #......=> "\""
puts "\\".to_json # => "\\"
puts "𤘩宮城".to_json(ascii_only: true) # => "\ud851\ude29\u5bae\u57ce"
//}... -
JSON
:: Generator :: GeneratorMethods :: Array # to _ json(state _ or _ hash = nil) -> String (51805.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 (51805.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 (51805.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 (51805.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 # => "{\"name\":\"tanaka\",\"age\":19}"
//}... -
JSON
:: Generator :: GeneratorMethods :: Integer # to _ json(state _ or _ hash = nil) -> String (51805.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 (51805.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 (51805.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 (51235.0) -
Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
...Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。
pretty_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブ......options JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。
//emlist[例][ruby]{
require "json"
hash......"tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}
puts JSON.pretty_generate(hash)
# => {
# "name": "tanaka",
# "age": 19
# }
puts JSON.pretty_generate(hash, space: "\t")
# => {
# "name": "tanaka",
# "age": 19
# }
//}
@see JSON.#generate... -
JSON
. # pretty _ unparse(object , options = nil) -> String (51235.0) -
Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
...Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。
pretty_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブ......options JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。
//emlist[例][ruby]{
require "json"
hash......"tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}
puts JSON.pretty_generate(hash)
# => {
# "name": "tanaka",
# "age": 19
# }
puts JSON.pretty_generate(hash, space: "\t")
# => {
# "name": "tanaka",
# "age": 19
# }
//}
@see JSON.#generate... -
JSON
:: Ext :: Generator :: State (51103.0) -
Alias of JSON::State
...Alias of JSON::State... -
JSON
:: State (51103.0) -
Ruby オブジェクトから JSON 形式の文字列を生成する間、 JSON 形式の文字列を生成するための設定を保持しておくために使用するクラスです。
...Ruby オブジェクトから JSON 形式の文字列を生成する間、
JSON 形式の文字列を生成するための設定を保持しておくために使用するクラスです。... -
JSON
:: State . new(options = {}) -> JSON :: State (43189.0) -
自身を初期化します。
...字列を指定します。デフォルトは空文字列です。
: :space
JSON 形式の文字列のトークン間に挿入する文字列を指定します。デフォルトは空文字列です。
: :space_before
JSON 形式の文字列中で JavaScript のオブジェクトを表す部分......。デフォルトは空文字列です。
: :object_nl
JSON 形式の文字列中に現れる JavaScript のオブジェクトの行末に挿入する文字列を指定します。
デフォルトは空文字列です。
: :array_nl
JSON 形式の文字列中に現れる JavaScript の配列......ジェクトの循環をチェックします。
この動作がデフォルトです。
: :allow_nan
真を指定した場合、JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することを許すようになります。
偽を指定した場合、これらの値を生成しよう... -
JSON
:: State # max _ nesting -> Integer (42487.0) -
生成される JSON 形式の文字列のネストの深さの最大値を返します。
... JSON 形式の文字列のネストの深さの最大値を返します。
この値がゼロである場合は、ネストの深さのチェックを行いません。
//emlist[例 ネストの深さチェックを行う][ruby]{
require "json"
json_state = JSON::State.new(max_nesting: 2)
json_s......# => 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 # object _ nl -> String (42397.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::State.new(object_nl: "\n")
json_state.object_nl # => "\n"
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => [1,2,{
# "name":"tanaka",
# "age":19
# }]
//}... -
JSON
:: State # space -> String (42397.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_state.space # => "\t"
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => [1,2,{"name": "tanaka","age": 19}]
//}... -
JSON
:: State # space _ before -> String (42397.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, { n......ame: "tanaka", age: 19 }], json_state)
# => [1,2,{"name":"tanaka","age":19}]
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}]
//}... -
JSON
:: State # configure(options = {}) -> self (42385.0) -
与えられたハッシュで自身を設定します。
...ーについては JSON::State.new を参照してください。
@param options このオブジェクトの設定をするためのハッシュを指定します。
//emlist[例][ruby]{
require "json"
json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "va......lue1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"
json_state.configure(indent: " ")
json_state.indent # => " "
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{ \"key1\":\"value1\", \"key2\":\"value2\"}"
//}
@see JSON::State.new... -
JSON
:: State # merge(options = {}) -> self (42385.0) -
与えられたハッシュで自身を設定します。
...ーについては JSON::State.new を参照してください。
@param options このオブジェクトの設定をするためのハッシュを指定します。
//emlist[例][ruby]{
require "json"
json_state = JSON::State.new(indent: "\t")
json_state.indent # => "\t"
JSON.generate({key1: "va......lue1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"
json_state.configure(indent: " ")
json_state.indent # => " "
JSON.generate({key1: "value1", key2: "value2"}, json_state)
# => "{ \"key1\":\"value1\", \"key2\":\"value2\"}"
//}
@see JSON::State.new... -
JSON
:: State # max _ nesting=(depth) (42379.0) -
生成される JSON 形式の文字列のネストの深さの最大値をセットします。
...生成される JSON 形式の文字列のネストの深さの最大値をセットします。
この値にゼロをセットすると、ネストの深さのチェックを行いません。
//emlist[例][ruby]{
require "json"
json_state = JSON::State.new(max_nesting: 2)
json_state.max_nestin......g # => 2
JSON.generate([[]], json_state)
json_state.max_nesting = 3
json_state.max_nesting # => 3
JSON.generate([[[[]]]], json_state) # => JSON::NestingError
//}... -
JSON
:: State # object _ nl=(string) (42379.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)
# => [1,2,{"name":"tanaka","age":19}]
json_state.object_nl = "\n"
json_state.object_nl # => "\n"
puts JSON.generate([1, 2, {......name: "tanaka", age: 19 }], json_state)
# => [1,2,{
# "name":"tanaka",
# "age":19
# }]
//}... -
JSON
:: State # space=(string) (42379.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 = "\t"
json_state.space # => "\t"
puts JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => [1,2,{"name": "tanaka","age": 19}]
//}... -
JSON
:: State # space _ before=(string) (42379.0) -
JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の 前に挿入する文字列をセットします。
...
JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列をセットします。
@param string JSON 形式の文字列中で JavaScript のオブジェクトを表す部分にある ':' の
前に挿入する文字列......uire "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}]
json_state.space_before = " "
json_state.space_before # => " "
puts JSON.gene......rate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => [1,2,{"name" :"tanaka","age" :19}]
//}... -
JSON
:: State # array _ nl -> String (42289.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) (42277.0) -
インデントに使用する文字列をセットします。
...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.generate({key1: "value1", key2: "value2"}, json_state)
# => "{... -
JSON
:: State # array _ nl=(str) (42253.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 (42241.0) -
NaN, Infinity, -Infinity を生成できる場合、真を返します。 そうでない場合は偽を返します。
...finity を生成できる場合、真を返します。
そうでない場合は偽を返します。
//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 (42223.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
:: State # indent -> String (42187.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 (42133.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,... -
JSON
:: State # to _ hash -> Hash (42133.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,... -
JSON
:: State # generate(obj) -> String (42103.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 (42055.0) -
ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。 そうでない場合に偽を返します。
...ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。
そうでない場合に偽を返します。... -
JSON
:: State # depth=(depth) (42055.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 (42007.0) -
Return the value returned by method name.
Return the value returned by method name. -
JSON
:: State # []=(name , value) (42007.0) -
Set the attribute name to value.
Set the attribute name to value. -
JSON
:: State # buffer _ initial _ length -> Integer (42007.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) (42007.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 (42007.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 (42007.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) (42007.0) -
If set to true, enables the quirks_mode mode.
If set to true, enables the quirks_mode mode. -
JSON
:: State # quirks _ mode? -> bool (42007.0) -
Returns true, if quirks mode is enabled. Otherwise returns false.
Returns true, if quirks mode is enabled. Otherwise returns false.