3件ヒット
[1-3件を表示]
(0.016秒)
クラス
-
JSON
:: Parser (1) -
JSON
:: State (2)
キーワード
- []= (1)
- parse (1)
-
quirks
_ mode= (1)
検索結果
-
JSON
:: State # []=(name , value) (58.0) -
Set the attribute name to value.
Set the attribute name to value. -
JSON
:: State # quirks _ mode=(enable) (58.0) -
If set to true, enables the quirks_mode mode.
If set to true, enables the quirks_mode mode. -
JSON
:: Parser # parse -> object (28.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...