jsonfmt

package
v3.0.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package jsonfmt provides a Formatter for JSON files.

The formatter uses github.com/tidwall/pretty for canonical output. JSON has no comments, so comment preservation is not applicable.

Defaults:

  • 2-space indentation
  • sorted keys
  • trailing newline

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOptions

func DefaultOptions() formatter.Options

DefaultOptions returns the default formatting options for JSON.

Types

type Formatter

type Formatter struct{}

Formatter formats JSON files to canonical style. It is stateless and safe for concurrent use.

func (Formatter) Format

func (Formatter) Format(src []byte, opts formatter.Options) ([]byte, error)

Format returns the canonically formatted version of src. Returns an error if src is not valid JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL