るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
14件ヒット [1-14件を表示] (0.030秒)

別のキーワード

  1. erb u
  2. util u
  3. matrix u
  4. encoding koi8_u
  5. _builtin koi8_u

検索結果

JSON::Parser#source -> String (18310.0)

現在のソースのコピーを返します。

...現在のソースのコピーを返します。

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

parser = JSON::Parser.new(DATA.read)
print parser.source

# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":20
# => },
# => "Suzuki": {
# => "name":"suzuki",
# => "age":25
# => }
#...

JSON::State#buffer_initial_length -> Integer (18310.0)

This integer returns the current initial length of the buffer.

This integer returns the current initial length of the buffer.

JSON::State#buffer_initial_length=(length) (18310.0)

This sets the initial length of the buffer to length, if length > 0, otherwise its value isn't changed.

This sets the initial length of the buffer to length, if length > 0,
otherwise its value isn't changed.

JSON::State#check_circular? -> bool (18310.0)

循環参照のチェックを行う場合は、真を返します。 そうでない場合は偽を返します。

...y]{
require "json"

a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s = JSON.state.new
begin
JSON
.generate(a, s)
rescue JSON::NestingErr...
...or => e
[e, s.max_nesting, s.check_circular?] # => [#<JSON::NestingError: nesting of 100 is too deep>, 100, true]
end
//}

//emlist[例 ネストをチェックしないケース][ruby]{
require "json"

a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...
...[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
s2 = JSON.state.new(max_nesting: 0)
json
= JSON.generate(a, s2)
[json, s2.max_nesting, s2.check_circular?] # => ["[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...

JSON::State#configure(options = {}) -> self (18310.0)

与えられたハッシュで自身を設定します。

...ーについては JSON::State.new を参照してください。

@param options このオブジェクトの設定をするためのハッシュを指定します。

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

json
_state = JSON::State.new(indent: "\t")
json
_state.indent # => "\t"
JSON
.generate({key1: "va...
...lue1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"

json
_state.configure(indent: " ")
json
_state.indent # => " "
JSON
.generate({key1: "value1", key2: "value2"}, json_state)
# => "{ \"key1\":\"value1\", \"key2\":\"value2\"}"
//}

@see JSON::State.new...

絞り込み条件を変える

JSON::State#quirks_mode -> bool (18310.0)

Returns true, if quirks mode is enabled. Otherwise returns false.

Returns true, if quirks mode is enabled. Otherwise returns false.

JSON::State#quirks_mode=(enable) (18310.0)

If set to true, enables the quirks_mode mode.

If set to true, enables the quirks_mode mode.

JSON::State#quirks_mode? -> bool (18310.0)

Returns true, if quirks mode is enabled. Otherwise returns false.

Returns true, if quirks mode is enabled. Otherwise returns false.

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

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

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

"true" という文字列を返します。

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

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

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

JSON::State#merge(options = {}) -> self (9010.0)

与えられたハッシュで自身を設定します。

...ーについては JSON::State.new を参照してください。

@param options このオブジェクトの設定をするためのハッシュを指定します。

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

json
_state = JSON::State.new(indent: "\t")
json
_state.indent # => "\t"
JSON
.generate({key1: "va...
...lue1", key2: "value2"}, json_state)
# => "{\t\"key1\":\"value1\",\t\"key2\":\"value2\"}"

json
_state.configure(indent: " ")
json
_state.indent # => " "
JSON
.generate({key1: "value1", key2: "value2"}, json_state)
# => "{ \"key1\":\"value1\", \"key2\":\"value2\"}"
//}

@see JSON::State.new...

絞り込み条件を変える

OpenStruct#to_json(*args) -> String (9007.0)

自身を JSON 形式の文字列に変換して返します。

...自身を JSON 形式の文字列に変換して返します。

内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡...
...されます。

@see JSON::Generator::GeneratorMethods::Hash#to_json...

Struct#to_json(*args) -> String (9007.0)

自身を JSON 形式の文字列に変換して返します。

...自身を JSON 形式の文字列に変換して返します。

内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡...
...されます。

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

Person = Struct.new(:name, :age)
Person.new("tanaka", 29).to_json # => "{\"json_class\":\"Person\",\"v\":[\"tanaka\",29]}"
//}

@see JSON::Generator::GeneratorMethods::Hash#to_json...

JSON::State#[]=(name, value) (310.0)

Set the attribute name to value.

Set the attribute name to value.

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

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

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

自身のエンコードは UTF-8 であるべきです。
"\u????" のように UTF-16 ビッグエンディアンでエンコードされた文字列を返すことがあります。

@param state_or_hash 生成する JSON 形式の文字...
... JSON::State のインスタンスか、
JSON
::State.new の引数と同じ Hash を
指定します。

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

puts "test".to_json # => "test"
puts '"'.to_json #...
...=> "\""
puts "\\".to_json # => "\\"
puts "𤘩宮城".to_json(ascii_only: true) # => "\ud851\ude29\u5bae\u57ce"
//}...