るりまサーチ

最速Rubyリファレンスマニュアル検索!
144件ヒット [1-100件を表示] (0.042秒)
トップページ > クエリ:object[x] > クエリ:>[x] > ライブラリ:json[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. json object

クラス

キーワード

検索結果

<< 1 2 > >>

JSON::State#object_nl -> String (6228.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::Generator::GeneratorMethods::String#to_json_raw_object -> Hash (6210.0)

生の文字列を格納したハッシュを生成します。

... JSON に変換する場合に使用してください。

require 'json'
"にほんご".encode("euc-jp").to_json_raw_object
# => {"json_class"=>"String", "raw"=>[164, 203, 164, 219, 164, 243, 164, 180]}
"にほんご".encode("euc-jp").to_json # source sequence is illegal/malformed (JSON::Ge...

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (3109.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
//}...

Kernel#JSON(object, options = {}) -> object (311.0)

第一引数に与えられたオブジェクトの種類によって Ruby のオブジェクトか JSON 形式の文字列を返します。

...ェクトか JSON 形式の文字列を返します。

第一引数に文字列のようなオブジェクトを指定した場合は、それを JSON.#parse を用いてパースした結果を返します。
そうでないオブジェクトを指定した場合は、それを JSON.#generate を...
...

@param object 任意のオブジェクトを指定します。

@param options JSON.#parse, JSON.#generate に渡すオプションを指定します。

//emlist[例][ruby]{
require "json"

JSON
('[1,2,{"name":"tanaka","age":19}]')
# => [1, 2, {"name"=>"tanaka", "age"=>19}]

JSON
('[1,2,{"name":...
..."tanaka","age":19}]', symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}]
//}

@see JSON.#parse, JSON.#generate...

JSON::Parser#parse -> object (210.0)

現在のソースをパースして結果を 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::State#[](name) -> object (204.0)

Return the value returned by method name.

Return the value returned by method name.

Kernel#j(*objects) -> nil (203.0)

与えられたオブジェクトを JSON 形式の文字列で標準出力に一行で出力します。

...られたオブジェクトを JSON 形式の文字列で標準出力に一行で出力します。

@param objects JSON 形式で出力したいオブジェクトを指定します。

//emlist[例][ruby]{
require "json"

j([1,2,{"name" => "tanaka","age" => 19}])
# => [1,2,{"name":"tanaka","age":19...

Kernel#jj(*objects) -> nil (203.0)

与えられたオブジェクトを JSON 形式の文字列で標準出力に人間に読みやすく整形して出力します。

...ジェクトを JSON 形式の文字列で標準出力に人間に読みやすく整形して出力します。

@param objects JSON 形式で出力したいオブジェクトを指定します。

//emlist[例][ruby]{
require "json"

jj([1,2,{"name" => "tanaka","age" => 19}])
# => [
# 1,
#...

JSON::Generator::GeneratorMethods::String#to_json_raw -> String (125.0)

自身に対して JSON::Generator::GeneratorMethods::String#to_json_raw_object を呼び出して JSON::Generator::GeneratorMethods::Hash#to_json した結果を返します。

...自身に対して JSON::Generator::GeneratorMethods::String#to_json_raw_object を呼び出して JSON::Generator::GeneratorMethods::Hash#to_json した結果を返します。

@see JSON::Generator::GeneratorMethods::String#to_json_raw_object, JSON::Generator::GeneratorMethods::Hash#to_json...
<< 1 2 > >>