json

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package json provides the JSON configuration decoder for CONGA applications.

Register Decode with conga.App.RegisterDecoder to enable JSON configuration support:

app.RegisterDecoder(".json", json.Decode)

Key Mapping

A top-level JSON key matches a flag's config tag as written or, when it has no tag, the flag name spelled in the app's key casing (conga.ConfigKeyCase, kebab-case by default). Other spellings and letter cases are unknown fields:

{
  "port": 8080,
  "database-url": "postgres://localhost/db",
  "max-retries": 5
}

Strictness

Decoding follows encoding/json/v2 semantics and rejects inputs that RFC 8259 leaves ambiguous: duplicate object member names and invalid UTF-8 in strings are errors rather than silently accepted. Reported errors carry the byte offset and JSON pointer of the offending value. Syntax errors, trailing content after the first JSON document, and non-object top-level values wrap ErrParse. A JSON null document decodes to an empty map.

Numbers

Numbers are decoded from their literal text rather than through float64, so integers bind exactly. An integer literal decodes to int64, or to uint64 when it exceeds the int64 range. A literal with a fraction or exponent decodes to float64. An integer outside both 64-bit ranges, or a number that overflows float64, wraps ErrParse.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrParse indicates a syntax or parsing error in JSON configuration.
	ErrParse = errors.New("json parse error")
)

Functions

func Decode

func Decode(data []byte) (map[string]any, error)

Decode decodes JSON bytes into the generic map[string]any structure the configuration engine matches against flag bindings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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