るりまサーチ

最速Rubyリファレンスマニュアル検索!
231件ヒット [201-231件を表示] (0.161秒)
トップページ > クエリ:i[x] > クエリ:-[x] > クエリ:require[x] > クエリ:to_json[x]

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

検索結果

<< < 1 2 3 >>

JSON::Generator::GeneratorMethods::TrueClass#to_json(state_or_hash = nil) -> String (18313.0)

自身から生成した JSON 形式の文字列を返します。

...る JSON 形式の文字列をカスタマイズするため
に JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。

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

true.to_json # => "true"
//}...

JSON::Generator::GeneratorMethods::String#to_json_raw_object -> Hash (9237.0)

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

...TF-8 の文字列ではなく生の文字列を 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::GeneratorError)...

JSON.create_id -> String (6218.0)

json_create メソッドで使用するクラスを決定するために使用する値を返します。

...

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

class User
attr :id, :name
def initialize(id, name)
@id, @name = id, name
end

def self.json_create(object)
new(object['id'], object["name"])
end

def as_json(*)
{
JSON.create_id => self.class.name,
"id" => id,
"name...
..." => name,
}
end

def to_json(*)
as_json.to_json
end
end

json = JSON.generate(User.new(1, "tanaka"))
json # => "{\"json_class\":\"User\",\"id\":1,\"name\":\"tanaka\"}"
JSON.parse(json, create_additions: true)
# => #<User:0x0000557709b269e0 @id=1, @name="tanaka">
//}...
<< < 1 2 3 >>