6件ヒット
[1-6件を表示]
(0.080秒)
種類
- インスタンスメソッド (4)
- 特異メソッド (1)
- クラス (1)
クラス
-
JSON
:: Parser (3) -
JSON
:: State (2)
検索結果
先頭5件
-
JSON
:: CircularDatastructure (18007.0) -
JSON 形式の文字列を生成するときに循環するデータ構造があるときに発生する例外です。
...JSON 形式の文字列を生成するときに循環するデータ構造があるときに発生する例外です。... -
JSON
:: State # depth -> Integer (55.0) -
This integer returns the current depth of data structure nesting.
This integer returns the current depth of data structure nesting. -
JSON
:: State # depth=(depth) (55.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
:: Parser . new(source , options => {}) -> JSON :: Parser (43.0) -
パーサを初期化します。
...も付加情報を生成しません。デフォルトは真です。
: :object_class
JSON のオブジェクトを変換するクラスを指定します。デフォルトは Hash です。
: :array_class
JSON の配列を変換するクラスを指定します。デフォルトは Array です......文字列を指定します。
@param options オプションを指定するためのハッシュです。
//emlist[例][ruby]{
require 'json'
parser = JSON::Parser.new(DATA.read)
print parser.source
# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki":......"age":25
}
}
//}
//emlist[例 object_class を指定する][ruby]{
require 'json'
class Person
attr_accessor :name, :age
def []=(key, value)
instance_variable_set("@#{key}", value)
end
end
parser = JSON::Parser.new(DATA.read, object_class: Person)
person = parser.parse
person.class... -
JSON
:: Parser # parse -> object (25.0) -
現在のソースをパースして結果を Ruby のオブジェクトとして返します。
...uby のオブジェクトとして返します。
//emlist[例][ruby]{
require 'json'
class Person
attr_accessor :name, :age
def []=(key, value)
instance_variable_set("@#{key}", value)
end
end
parser = JSON::Parser.new(DATA.read, object_class: Person)
person = parser.parse
person.class......# => Person
person.name # => "tanaka"
person.age # => 20
__END__
{
"name":"tanaka",
"age":20
}
//}
@see JSON::Parser#source... -
JSON
:: Parser # source -> String (25.0) -
現在のソースのコピーを返します。
...現在のソースのコピーを返します。
//emlist[例][ruby]{
require 'json'
parser = JSON::Parser.new(DATA.read)
print parser.source
# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# => "age":25
# => }
#...