pub struct FracturedJsonOptions {Show 22 fields
pub json_eol_style: EolStyle,
pub max_total_line_length: usize,
pub max_inline_complexity: isize,
pub max_compact_array_complexity: isize,
pub max_table_row_complexity: isize,
pub max_prop_name_padding: usize,
pub colon_before_prop_name_padding: bool,
pub table_comma_placement: TableCommaPlacement,
pub min_compact_array_row_items: usize,
pub always_expand_depth: isize,
pub nested_bracket_padding: bool,
pub simple_bracket_padding: bool,
pub colon_padding: bool,
pub comma_padding: bool,
pub comment_padding: bool,
pub number_list_alignment: NumberListAlignment,
pub indent_spaces: usize,
pub use_tab_to_indent: bool,
pub prefix_string: String,
pub comment_policy: CommentPolicy,
pub preserve_blank_lines: bool,
pub allow_trailing_commas: bool,
}Expand description
Configuration options for JSON formatting.
This struct contains all settings that control how JSON is formatted.
Use Default::default() or FracturedJsonOptions::recommended()
to get sensible defaults, then modify individual fields as needed.
§Example
use fracturedjson::{FracturedJsonOptions, EolStyle, CommentPolicy};
let mut options = FracturedJsonOptions::default();
options.max_total_line_length = 80;
options.indent_spaces = 2;
options.comment_policy = CommentPolicy::Preserve;Fields§
§json_eol_style: EolStyleLine ending style for the output. Default: EolStyle::Lf.
max_total_line_length: usizeMaximum length of a line before it’s broken into multiple lines. Default: 120.
max_inline_complexity: isizeMaximum nesting depth for arrays/objects to be written on a single line. A value of 0 means only primitive values can be inlined. A value of 1 allows simple arrays/objects with primitive elements. Set to -1 to disable inline formatting entirely. Default: 2.
max_compact_array_complexity: isizeMaximum nesting depth for arrays to use compact multi-line formatting (multiple items per line). Set to -1 to disable. Default: 2.
max_table_row_complexity: isizeMaximum nesting depth for arrays/objects to be formatted as aligned tables. Set to -1 to disable table formatting. Default: 2.
max_prop_name_padding: usizeMaximum number of spaces to use for property name padding in table format. If aligning property names would require more padding than this, alignment is skipped for that container. Default: 16.
colon_before_prop_name_padding: boolIf true, the colon comes before the property name padding.
Example with true: "a": 1 vs "aaa": 2
Example with false: "a" : 1 vs "aaa": 2
Default: false.
table_comma_placement: TableCommaPlacementWhere to place commas in table-formatted output.
Default: TableCommaPlacement::BeforePaddingExceptNumbers.
min_compact_array_row_items: usizeMinimum number of items required per row when formatting arrays in compact multi-line mode. Default: 3.
always_expand_depth: isizeDepth at which containers are always expanded (never inlined). Containers at this depth or shallower will always be multi-line. Set to -1 to disable (allow inlining at any depth). Default: -1.
nested_bracket_padding: boolAdd spaces inside brackets for nested containers: [ [1, 2] ] vs [[1, 2]].
Default: true.
simple_bracket_padding: boolAdd spaces inside brackets for simple (non-nested) containers: [ 1, 2 ] vs [1, 2].
Default: false.
colon_padding: boolAdd a space after colons in objects: "key": value vs "key":value.
Default: true.
comma_padding: boolAdd a space after commas: [1, 2, 3] vs [1,2,3].
Default: true.
comment_padding: boolAdd a space before comments: value /*comment*/ vs value/*comment*/.
Default: true.
number_list_alignment: NumberListAlignmentAlignment style for numbers in array tables.
Default: NumberListAlignment::Decimal.
indent_spaces: usizeNumber of spaces per indentation level. Ignored if use_tab_to_indent is true.
Default: 4.
use_tab_to_indent: boolUse tabs instead of spaces for indentation. Default: false.
prefix_string: StringA string to prepend to every line of output. Useful for embedding formatted JSON within other content. Default: empty string.
comment_policy: CommentPolicyHow to handle comments in the input.
Default: CommentPolicy::TreatAsError.
preserve_blank_lines: boolPreserve blank lines from the input in the output.
Only meaningful when comment_policy is not TreatAsError.
Default: false.
allow_trailing_commas: boolAllow trailing commas in the input (non-standard JSON). Default: false.
Implementations§
Source§impl FracturedJsonOptions
impl FracturedJsonOptions
Sourcepub fn recommended() -> Self
pub fn recommended() -> Self
Creates a new FracturedJsonOptions with recommended settings.
Currently identical to Default::default(), but may include
improved defaults in future versions without breaking compatibility.
Trait Implementations§
Source§impl Clone for FracturedJsonOptions
impl Clone for FracturedJsonOptions
Source§fn clone(&self) -> FracturedJsonOptions
fn clone(&self) -> FracturedJsonOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more