json

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ParserFormat string = "JSON"

ParserFormat defines the standard identifier and file extension target for this provider.

View Source
const XERR_PKGCTX_PARSER xerrors.ErrorCode = "XCONFIG.PARSER.JSON"

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements the xconfig.Parser interface to read, parse, and merge data from structured JSON configuration files.

func NewParser

func NewParser() *Parser

NewParser instantiates an unconfigured pointer to a JSON Parser.

func (*Parser) Read

func (o *Parser) Read() (map[string]any, error)

Read processes all matched JSON configuration files, loads their byte content into memory, and unmarshals the syntax structures into a single consolidated generic map.

Key behaviors:

  • Loops through every identified path and aggregates properties into a shared map workspace.
  • Safely bypasses empty file documents instead of failing or erasing previous updates.
  • Note: Complex nested object trees inside JSON fields are captured as map[string]any. For consistent flat-key overrides (e.g. key.subkey), input files should adopt flattened properties.

Returns a merged generic map of configurations, or an error if any file read or syntax decoding fails.

func (*Parser) SetOptions

func (o *Parser) SetOptions(opts xconfig.Options) error

SetOptions executes strict path validation against the incoming criteria. It configuration targets must satisfy single-path exclusivity (File vs Dir vs ConfigPath) ensuring unambiguous resolution of JSON files.

Jump to

Keyboard shortcuts

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