るりまサーチ

最速Rubyリファレンスマニュアル検索!
869件ヒット [1-100件を表示] (0.139秒)
トップページ > クエリ:-[x] > クエリ:E[x] > ライブラリ:json[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

JSON::Generator::GeneratorMethods::String::Extend.json_create(hash) -> String (12202.0)

JSON のオブジェクトから Ruby の文字列を生成して返します。

...
JSON
のオブジェクトから Ruby の文字列を生成して返します。

@param hash キーとして "raw" という文字列を持ち、その値として数値の配列を持つハッシュを指定します。

require 'json'
String.json_create({"raw" => [0x41, 0x42, 0x43]}) # => "A...

JSON::Generator::GeneratorMethods::String#to_json_raw_object -> Hash (9220.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.generator -> JSON::Ext::Generator (6302.0)

JSON ライブラリがジェネレータとして使用するモジュールを返します。

...
JSON
ライブラリがジェネレータとして使用するモジュールを返します。...

JSON.parser -> JSON::Ext::Parser (6302.0)

JSON ライブラリがパーサとして使用するクラスを返します。

...
JSON
ライブラリがパーサとして使用するクラスを返します。

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

JSON
.parser # => JSON::Ext::Parser
//}...

JSON.state -> JSON::Ext::Generator::State (6302.0)

JSON ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。

...
JSON
ライブラリがジェネレータの状態を表すクラスとして使用するクラスを返します。

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

JSON
.state # => JSON::Ext::Generator::State
//}...

絞り込み条件を変える

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

This integer returns the current initial length of the buffer.

...This integer returns the current initial length of the buffer....

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

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

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

.../emlist[例 ネストをチェックするケース][ruby]{
require "json"

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

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

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

JSON.create_id -> String (6208.0)

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

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

デフォルトは "json_class" です。

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

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

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

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

def to_json(*)
as_json.to_json
e
nd
e
nd

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">
//}...

JSON::Parser.new(source, options => {}) -> JSON::Parser (6208.0)

パーサを初期化します。

...

: :max_nesting
データ構造のネストの深さの最大値を指定します。デフォルトは 19 です。
チェックを無効にするにはゼロまたは偽を指定してください。
: :allow_nan
真を指定すると 4627 を無視して NaN, Infinity, -Infinity をパ...
...:create_additions
偽を指定するとマッチするクラスや ID があっても付加情報を生成しません。デフォルトは真です。
: :object_class
JSON
のオブジェクトを変換するクラスを指定します。デフォルトは Hash です。
: :array_class
JSON
...
...urce パーサの元となる文字列を指定します。

@param options オプションを指定するためのハッシュです。

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

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

# => {
# => "Tanaka": {
# => "name":"tanaka",
# => "age":...

絞り込み条件を変える

<< 1 2 3 ... > >>