ライブラリ
- ビルトイン (2)
- json (28)
-
json
/ add / bigdecimal (1) -
json
/ add / complex (1) -
json
/ add / rational (1) -
json
/ add / symbol (1)
クラス
- BigDecimal (1)
- Class (1)
- Complex (1)
-
JSON
:: State (15) - Object (2)
- Rational (1)
- Symbol (1)
モジュール
-
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) - Kernel (3)
キーワード
- []= (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)
- j (1)
- jj (1)
-
json
_ creatable? (1) - merge (1)
-
object
_ nl (1) -
object
_ nl= (1) -
quirks
_ mode (1) -
quirks
_ mode= (1) -
quirks
_ mode? (1) -
to
_ json (13) -
yield
_ self (2)
検索結果
先頭5件
- Kernel
# JSON(object , options = {}) -> object - Class
# json _ creatable? -> bool - JSON
:: Generator :: GeneratorMethods :: FalseClass # to _ json(state _ or _ hash = nil) -> String - JSON
:: Generator :: GeneratorMethods :: Float # to _ json(state _ or _ hash = nil) -> String - JSON
:: Generator :: GeneratorMethods :: NilClass # to _ json(state _ or _ hash = nil) -> String
-
Kernel
# JSON(object , options = {}) -> object (63517.0) -
第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。
第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。
第一引数に文字列のようなオブジェクトを指定した場合は、それを JSON.#parse を用いてパースした結果を返します。
そうでないオブジェクトを指定した場合は、それを JSON.#generate を用いて変換した結果を返します。
@param object 任意のオブジェクトを指定します。
@param options JSON.#parse, JSON.#generate に渡すオプションを指定します。
//emlist[例][ruby]{
require "json... -
Class
# json _ creatable? -> bool (36745.0) -
シリアライズされた JSON 形式の文字列から、インスタンスを作成するのにこのクラスを使用できる場合は 真を返します。そうでない場合は、偽を返します。
シリアライズされた JSON 形式の文字列から、インスタンスを作成するのにこのクラスを使用できる場合は
真を返します。そうでない場合は、偽を返します。
このメソッドが真を返すクラスは json_create というメソッドを実装していなければなりません。
また json_create の第一引数は必要なデータを含むハッシュを期待しています。
//emlist[例][ruby]{
require "json"
String.json_creatable? # => true
Dir.json_creatable? # => false
//} -
JSON
:: Generator :: GeneratorMethods :: FalseClass # to _ json(state _ or _ hash = nil) -> String (36745.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 (36745.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 :: NilClass # to _ json(state _ or _ hash = nil) -> String (36745.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 (36745.0) -
自身から生成した JSON 形式の文字列を返します。
自身から生成した JSON 形式の文字列を返します。
"true" という文字列を返します。
@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
true.to_json # => "true"
//} -
JSON
:: Generator :: GeneratorMethods :: Object # to _ json(state _ or _ hash = nil) -> String (27799.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 (27799.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 (27745.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 :: Hash # to _ json(state _ or _ hash = nil) -> String (27745.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 (27745.0) -
自身から生成した JSON 形式の文字列を返します。
自身から生成した JSON 形式の文字列を返します。
@param state_or_hash 生成する JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
10.to_json # => "10"
//} -
JSON
:: State # object _ nl -> String (27550.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 # object _ nl=(string) (27550.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 # check _ circular? -> bool (27484.0) -
循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。
循環参照のチェックを行う場合は、真を返します。
そうでない場合は偽を返します。
//emlist[例 ネストをチェックするケース][ruby]{
require "json"
a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]... -
BigDecimal
# to _ json(*args) -> String (27481.0) -
自身を JSON 形式の文字列に変換して返します。
自身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。
@param args 使用しません。
//emlist[例][ruby]{
require 'json/add/bigdecimal'
BigDecimal('0.123456789123456789').to_json # => "{\"json_class\":\"BigDecimal\",\"b\":\"36:0.123456789123456789e0\"}"
//... -
Complex
# to _ json(*args) -> String (27481.0) -
自身を JSON 形式の文字列に変換して返します。
自身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。
@param args 使用しません。
//emlist[例][ruby]{
require 'json/add/complex'
Complex(2, 3).to_json # => "{\"json_class\":\"Complex\",\"r\":2,\"i\":3}"
//}
@see JSON::Generator::GeneratorMethods::Hash... -
Rational
# to _ json(*args) -> String (27481.0) -
自身を JSON 形式の文字列に変換して返します。
自身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。
@param args 使用しません。
//emlist[例][ruby]{
require 'json/add/rational'
Rational(1, 3).to_json # => "{\"json_class\":\"Rational\",\"n\":1,\"d\":3}"
//}
@see JSON::Generator::GeneratorMethods::H... -
JSON
:: State # array _ nl -> String (27478.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"
//} -
Symbol
# to _ json(*args) -> String (27463.0) -
自身を JSON 形式の文字列に変換して返します。
自身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。
@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。
@see JSON::Generator::GeneratorMethods::Hash#to_json -
JSON
:: State # array _ nl=(str) (27460.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 (27430.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 # ascii _ only? -> bool (27352.0) -
ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。 そうでない場合に偽を返します。
ASCII 文字列のみを用いて JSON 形式の文字列を生成する場合に真を返します。
そうでない場合に偽を返します。 -
JSON
:: State # buffer _ initial _ length -> Integer (27304.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) (27304.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. -
Object
# yield _ self -> Enumerator (18340.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
self を引数としてブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
... -
Object
# yield _ self {|x| . . . } -> object (18340.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
self を引数としてブロックを評価し、ブロックの結果を返します。
//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}
値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。
//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
... -
JSON
:: State # configure(options = {}) -> self (9520.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 (9520.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\... -
Kernel
# j(*objects) -> nil (9388.0) -
与えられたオブジェクトを JSON 形式の文字列で標準出力に一行で出力します。
与えられたオブジェクトを JSON 形式の文字列で標準出力に一行で出力します。
@param objects JSON 形式で出力したいオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
j([1,2,{"name" => "tanaka","age" => 19}])
# => [1,2,{"name":"tanaka","age":19}]
//}
@see Kernel.#p -
Kernel
# jj(*objects) -> nil (9388.0) -
与えられたオブジェクトを JSON 形式の文字列で標準出力に人間に読みやすく整形して出力します。
与えられたオブジェクトを JSON 形式の文字列で標準出力に人間に読みやすく整形して出力します。
@param objects JSON 形式で出力したいオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
jj([1,2,{"name" => "tanaka","age" => 19}])
# => [
# 1,
# 2,
# {
# "name": "tanaka",
# "age": 19
# }
# ]
//}
@see Kernel.#pp -
JSON
:: State # []=(name , value) (9304.0) -
Set the attribute name to value.
Set the attribute name to value. -
JSON
:: State # quirks _ mode -> bool (9304.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) (9304.0) -
If set to true, enables the quirks_mode mode.
If set to true, enables the quirks_mode mode. -
JSON
:: State # quirks _ mode? -> bool (9304.0) -
Returns true, if quirks mode is enabled. Otherwise returns false.
Returns true, if quirks mode is enabled. Otherwise returns false.