class
JSON::Tight::Formatter
- JSON::Tight::Formatter
- Reference
- Object
Overview
Applies the layout strategies described on JSON::Tight. Build one
directly instead of calling JSON::Tight.generate to reuse it across
documents or to control the indent used by expanded layouts.
formatter = JSON::Tight::Formatter.new(width: 100, indent: 4)
formatter.format(STDOUT, value)
Defined in:
json-tight.crConstructors
Instance Method Summary
-
#format(io : IO, value : JSON::Any) : Nil
Writes value to io, formatted and ending in a newline.
-
#format(io : IO, value) : Nil
Writes value, which may be anything that responds to
#to_json, to io, formatted and ending in a newline. -
#format(io : IO, *, json : String) : Nil
Parses json and writes it to io, reformatted and ending in a newline.
-
#indent : Int32
Spaces per nesting level in expanded layouts.
-
#width : Int32
Width budget for a line's content, excluding leading indentation.
Constructor Detail
Instance Method Detail
Writes value to io, formatted and ending in a newline.
Writes value, which may be anything that responds to #to_json, to
io, formatted and ending in a newline.
Parses json and writes it to io, reformatted and ending in a
newline. Raises JSON::ParseException if json is not valid JSON.