FracturedJsonOptions

Struct FracturedJsonOptions 

Source
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: EolStyle

Line ending style for the output. Default: EolStyle::Lf.

§max_total_line_length: usize

Maximum length of a line before it’s broken into multiple lines. Default: 120.

§max_inline_complexity: isize

Maximum 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: isize

Maximum 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: isize

Maximum nesting depth for arrays/objects to be formatted as aligned tables. Set to -1 to disable table formatting. Default: 2.

§max_prop_name_padding: usize

Maximum 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: bool

If 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: TableCommaPlacement

Where to place commas in table-formatted output. Default: TableCommaPlacement::BeforePaddingExceptNumbers.

§min_compact_array_row_items: usize

Minimum number of items required per row when formatting arrays in compact multi-line mode. Default: 3.

§always_expand_depth: isize

Depth 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: bool

Add spaces inside brackets for nested containers: [ [1, 2] ] vs [[1, 2]]. Default: true.

§simple_bracket_padding: bool

Add spaces inside brackets for simple (non-nested) containers: [ 1, 2 ] vs [1, 2]. Default: false.

§colon_padding: bool

Add a space after colons in objects: "key": value vs "key":value. Default: true.

§comma_padding: bool

Add a space after commas: [1, 2, 3] vs [1,2,3]. Default: true.

§comment_padding: bool

Add a space before comments: value /*comment*/ vs value/*comment*/. Default: true.

§number_list_alignment: NumberListAlignment

Alignment style for numbers in array tables. Default: NumberListAlignment::Decimal.

§indent_spaces: usize

Number of spaces per indentation level. Ignored if use_tab_to_indent is true. Default: 4.

§use_tab_to_indent: bool

Use tabs instead of spaces for indentation. Default: false.

§prefix_string: String

A string to prepend to every line of output. Useful for embedding formatted JSON within other content. Default: empty string.

§comment_policy: CommentPolicy

How to handle comments in the input. Default: CommentPolicy::TreatAsError.

§preserve_blank_lines: bool

Preserve blank lines from the input in the output. Only meaningful when comment_policy is not TreatAsError. Default: false.

§allow_trailing_commas: bool

Allow trailing commas in the input (non-standard JSON). Default: false.

Implementations§

Source§

impl FracturedJsonOptions

Source

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

Source§

fn clone(&self) -> FracturedJsonOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FracturedJsonOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FracturedJsonOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.