るりまサーチ

最速Rubyリファレンスマニュアル検索!
120件ヒット [1-100件を表示] (0.024秒)
トップページ > クエリ:parse[x] > クエリ:Ruby[x] > 種類:モジュール関数[x]

別のキーワード

  1. time parse
  2. parser parse
  3. csv parse
  4. ripper parse
  5. psych parse_stream

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 > >>

JSON.#parse(source, options = {}) -> object (18142.0)

与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。

...与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。

@param source JSON 形式の文字列を指定します。

@param options オプションをハッシュで指定します。
指定可能なオプションは以下の通りです。

: :max_n...
...フォルトは偽です。

//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 (6154.0)

与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。

...与えられた JSON 形式の文字列を Ruby オブジェクトに変換して返します。

JSON.#parse よりも危険なデフォルト値が指定されているので
信頼できる文字列のみを入力として使用するようにしてください。

@param source JSON 形式の...
...す。

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

json_text = "[1,2,{\"name\":\"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) # => unexp...
...ected token at 'NaN]' (JSON::ParserError)
//}

@see JSON::Parser#parse...

JSON.#pretty_unparse(object, options = nil) -> String (3123.0)

Ruby のオブジェクトを JSON 形式の文字列に変換して返します。

...
Ruby
のオブジェクトを JSON 形式の文字列に変換して返します。

このメソッドは JSON.#generate よりも人間に読みやすい文字列を返します。

pretty_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブ...
...きます。
ハッシュを使用する場合指定可能なオプションは JSON.#generate を参照してください。

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

hash = { "name": "tanaka", "age": 19 }
puts JSON.generate(hash)
# => {"name":"tanaka","age":19}

puts JSON.pretty_generate(hash)...

JSON.#fast_unparse(object) -> String (3107.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...ることができるので、気をつけてください。

fast_unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

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

JSON.fast_generate({ name: "tanaka", age: 19 }) # => "...

JSON.#unparse(object, state = nil) -> String (3107.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...また、循環参照のチェックを行います。JSON::NaN, JSON::Infinity,
JSON::MinusInfinity を生成することもありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state...
...ます。

@raise JSON::CircularDatastructure 与えられたオブジェクトが循環参照を持つ場合に発生します。

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

JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space...

絞り込み条件を変える

Kernel.#caller(range) -> [String] | nil (43.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $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 (43.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $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 (43.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

def bar
foo
end

bar

#=> ["-:2:in `foo'", "-:10:in `bar'",...
...

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $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"]
//}...

JSON.#load_file!(filespec, opts = {}) -> object (29.0)

filespec で指定した JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。

...JSON 形式のファイルを Ruby オブジェクトとしてロードして返します。

@param filespec ファイル名を指定します。

@param options オプションをハッシュで指定します。指定可能なオプションは JSON.#parse! と同様です。

@see JSON.#parse!...
<< 1 2 > >>