Ruby 2.3.0 リファレンスマニュアル > ライブラリ一覧 > jsonライブラリ > JSON::Stateクラス > indent

instance method JSON::State#indent

indent -> String[permalink][rdoc]

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



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\"}"