144件ヒット
[1-100件を表示]
(0.073秒)
ライブラリ
- ビルトイン (36)
- json (84)
- uri (12)
-
webrick
/ httputils (12)
モジュール
- JSON (84)
- Kernel (48)
-
WEBrick
:: HTTPUtils (12)
キーワード
- URI (12)
- caller (36)
-
fast
_ unparse (12) -
load
_ file (12) -
load
_ file! (12) - parse! (12)
-
parse
_ header (12) -
pretty
_ unparse (12) - unparse (12)
検索結果
先頭5件
-
JSON
. # parse(source , options = {}) -> object (18220.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
...フォルトは偽です。
//emlist[例][ruby]{
require "json"
JSON.parse('[1,2,{"name":"tanaka","age":19}]')
# => [1, 2, {"name"=>"tanaka", "age"=>19}]
JSON.parse('[1,2,{"name":"tanaka","age":19}]', symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}]
//}
@see JSON::Parser#parse... -
JSON
. # parse!(source , options = {}) -> object (6232.0) -
与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
...与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。
JSON.#parse よりも危険なデフォルト値が指定されているので
信頼できる文字列のみを入力として使用するようにしてください。
@param source JSON 形式の......:\"tanaka\",\"age\":19}, NaN]"
JSON.parse!(json_text)
# => [1, 2, {"name"=>"tanaka", "age"=>19}, NaN]
JSON.parse!(json_text, symbolize_names: true)
# => [1, 2, {:name=>"tanaka", :age=>19}, NaN]
JSON.parse(json_text) # => unexpected token at 'NaN]' (JSON::ParserError)
//}
@see JSON::Parser#parse... -
WEBrick
:: HTTPUtils . # parse _ header(raw) -> Hash (6202.0) -
HTTP ヘッダをパースして結果をハッシュに格納して返します。
HTTP ヘッダをパースして結果をハッシュに格納して返します。
@param raw 生のヘッダを表す文字列を指定します。 -
JSON
. # fast _ unparse(object) -> String (3201.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...をつけてください。
fast_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
//emlist[例][ruby]{
require "json"
JSON.fast_generate({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"... -
JSON
. # pretty _ unparse(object , options = nil) -> String (3201.0) -
Ruby のオブジェクトを JSON 形式の文字列に変換して返します。
...字列に変換して返します。
このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。
pretty_unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param options......ash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}
puts JSON.pretty_generate(hash)
# => {
# "name": "tanaka",
# "age": 19
# }
puts JSON.pretty_generate(hash, space: "\t")
# => {
# "name": "tanaka",
# "age": 19
# }
//}
@see JSO... -
JSON
. # unparse(object , state = nil) -> String (3201.0) -
与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。
...また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。
unparse は将来削除される予定です。
@param object JSON 形式の文字列に変換するオブジェクトを指定します。
@param state......by]{
require "json"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: " ")
JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]"
//}
@see JSON::State, JSON.#p... -
Kernel
. # caller(range) -> [String] | nil (125.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_......le = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役......に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start = 1) -> [String] | nil (125.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_......le = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役......に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start , length) -> [String] | nil (125.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_......le = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役......に立つ debug 関数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}...