jsonlazy

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package jsonlazy implements delayed JSON encoding for values that do not implement json.Marshaler interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Marshaler

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

Marshaler implements a delayed JSON encoding for values.

func NewMarshaler

func NewMarshaler(v interface{}) *Marshaler

NewMarshaler returns a new Marshaler for the given value.

func (*Marshaler) MarshalJSON

func (m *Marshaler) MarshalJSON() ([]byte, error)

MarshalJSON implemnets the json.Marshaler interface.

func (*Marshaler) Once

func (m *Marshaler) Once() *OnceMarshaler

Once is a shorthand for jsonlazy.Once(m).

type OnceMarshaler

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

OnceMarshaler is a json.Marshaler that caches the result of MarshalJSON call.

func Once

func Once(m json.Marshaler) *OnceMarshaler

Once returns a new marshaler that caches the result of MarshalJSON call. That is, it calls MarshalJSON at most once.

func (*OnceMarshaler) MarshalJSON

func (m *OnceMarshaler) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

Jump to

Keyboard shortcuts

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