jsonutil

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package jsonutil provides JSON formatting utilities.

The package supports pretty printing with indentation. Keys are always sorted alphabetically by Go's json.Marshal, ensuring consistent output for diffing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryFormat

func TryFormat(value string) (string, bool)

TryFormat attempts to format a JSON string with indentation. Returns the formatted string and true if successful, or the original string and false if not valid JSON. This is useful for commands that need to know whether formatting was applied.

func TryFormatOrWarn

func TryFormatOrWarn(value string, errW io.Writer, name string) string

TryFormatOrWarn formats JSON or warns and returns original. If name is non-empty, includes it in the warning message.

func TryFormatOrWarn2

func TryFormatOrWarn2(v1, v2 string, errW io.Writer, name string) (string, string)

TryFormatOrWarn2 formats both JSONs or warns and returns originals. If name is non-empty, includes it in the warning message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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