hjson

package
v2.679.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package hjson provides HJSON encoding helpers and adapters used by go-service.

This package integrates HJSON encoding/decoding behind the go-service encoding abstraction. Decode rejects duplicate object keys and unknown destination fields.

Start with the package-level constructors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v2.506.0

func Marshal(v any) ([]byte, error)

Marshal encodes v as HJSON.

func Unmarshal added in v2.506.0

func Unmarshal(data []byte, v any) error

Unmarshal decodes HJSON data into v.

It uses Decode, so it rejects duplicate object keys and unknown destination fields.

Types

type Encoder

type Encoder struct{}

Encoder implements HJSON encoding and decoding.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder constructs an HJSON encoder.

This encoder is a thin adapter around github.com/hjson/hjson-go that satisfies github.com/alexfalkowski/go-service/v2/encoding.Encoder.

func (*Encoder) Decode

func (e *Encoder) Decode(r io.Reader, v any) error

Decode reads HJSON from r and decodes it into v.

In most cases v should be a pointer to the destination value (for example *MyStruct). Decode rejects duplicate object keys and unknown destination fields. Decode buffers all remaining input from r before decoding; callers should bound untrusted or potentially large readers before calling it.

func (*Encoder) Encode

func (e *Encoder) Encode(w io.Writer, v any) error

Encode writes v to w as HJSON.

Jump to

Keyboard shortcuts

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