るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.015秒)
トップページ > クエリ:json[x] > クエリ:indent=[x]

別のキーワード

  1. json to_json
  2. json state
  3. json parser
  4. json generate
  5. json []

ライブラリ

クラス

検索結果

JSON::State#indent=(string) (29160.0)

インデントに使用する文字列をセットします。

...ruby]{
require "json"

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