51件ヒット
[1-51件を表示]
(0.032秒)
種類
- インスタンスメソッド (22)
- 特異メソッド (11)
- ライブラリ (11)
- 文書 (7)
ライブラリ
- json (33)
クラス
-
JSON
:: Parser (33)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (7) - new (11)
- source (11)
検索結果
先頭5件
-
json (38100.0)
-
JSON (JavaScript Object Notation)を扱うライブラリです。
...JSON (JavaScript Object Notation)を扱うライブラリです。
このライブラリでは、JSON モジュールに JSON を操作するための代表的なメソッドが集められています。
詳細は JSON モジュールを参照してください。
JSON の仕様は 7159 を参照......y]{
require "json"
# JSON文字列をRubyのオブジェクトに変換する
json_str = '{"name": "Ruby", "age": 30}'
JSON.parse(json_str) # => {"name"=>"Ruby", "age"=>30}
# RubyのオブジェクトをJSON文字列に変換する
data = {"name" => "Ruby", "age" => 30}
JSON.dump(data) # => "{\"na... -
JSON
:: Parser # parse -> object (32131.0) -
現在のソースをパースして結果を Ruby のオブジェクトとして返します。
...返します。
//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 # => "ta......naka"
person.age # => 20
__END__
{
"name":"tanaka",
"age":20
}
//}
@see JSON::Parser#source... -
JSON
:: Parser . new(source , options => {}) -> JSON :: Parser (14255.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": {
# => "name"......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 # => Person
person.name # => "ta... -
JSON
:: Parser # source -> String (14018.0) -
現在のソースのコピーを返します。
...現在のソースのコピーを返します。
//emlist[例][ruby]{
require 'json'
parser = JSON::Parser.new(DATA.read)
print parser.source
# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# => "age":25
# => }
#... -
NEWS for Ruby 2
. 5 . 0 (18.0) -
NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...になりました 13812
=== 組み込みクラスの更新
* Array
* Array#append を追加 12746
* Array#prepend を追加 12746
* Data
* 非推奨になりました。C拡張のベースクラスでしたが、Rubyレベルに公開するのをやめました。3072
* Except......tion to a keyword argument
https://github.com/ruby/psych/pull/342
* Add :symbolize_names option to Psych.load, Psych.safe_load like JSON.parse
https://github.com/ruby/psych/pull/333, https://github.com/ruby/psych/pull/337
* Add Psych::Handler#event_location
https:...