json

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

ABOUTME: JSON manipulation utilities with schema support and streaming. ABOUTME: Enhanced JSON operations including merging, patching, and validation. Package json provides enhanced JSON manipulation utilities beyond the standard library. It includes schema-aware operations, streaming support, JSON merging and patching, and integration with the schema validation system for type-safe JSON handling.

Utilities include:

  • Schema-based JSON validation
  • JSON merging and patching
  • Streaming JSON processing
  • Pretty printing and formatting
  • JSON pointer operations

Package json provides an optimized JSON implementation with multiple backends

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(data []byte, path ...interface{}) jsoniter.Any

Get searches a path in json object and returns the JsonIter's Any object. Any is a data type that can be used to represent any JSON value with lazy parsing.

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal marshals the interface into a JSON byte array. It's a drop-in replacement for encoding/json.Marshal with better performance.

func MarshalIndent

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

MarshalIndent marshals the interface into a JSON byte array with indentation. It's a drop-in replacement for encoding/json.MarshalIndent with better performance.

func MarshalIndentWithBuffer

func MarshalIndentWithBuffer(v interface{}, buf *bytes.Buffer, prefix, indent string) error

MarshalIndentWithBuffer is an optimized version of MarshalIndent that reuses a provided buffer to minimize allocations. The buffer will be reset and used for the output.

func MarshalSchemaFast

func MarshalSchemaFast(schema *schemaDomain.Schema) ([]byte, error)

MarshalSchemaFast marshals a schema to JSON without indentation, using a pooled buffer This is the fastest option for schema serialization when indentation is not needed

func MarshalSchemaIndent

func MarshalSchemaIndent(schema *schemaDomain.Schema) ([]byte, error)

MarshalSchemaIndent marshals a schema to JSON with indentation, using a pooled buffer This is specifically optimized for the schema domain model and reduces allocations

func MarshalSchemaToString

func MarshalSchemaToString(schema *schemaDomain.Schema) (string, error)

MarshalSchemaToString marshals a schema to a JSON string with indentation This is convenience function for contexts where a string is preferred

func MarshalToString

func MarshalToString(v interface{}) (string, error)

MarshalToString marshals the interface into a JSON string. This is more efficient than Marshal followed by string conversion.

func MarshalWithBuffer

func MarshalWithBuffer(v interface{}, buf *bytes.Buffer) error

MarshalWithBuffer is an optimized version of Marshal that reuses a provided buffer to minimize allocations. The buffer will be reset and used for the output.

func NewDecoder

func NewDecoder(r io.Reader) *jsoniter.Decoder

NewDecoder returns a new decoder that reads from r.

func NewEncoder

func NewEncoder(w io.Writer) *jsoniter.Encoder

NewEncoder returns a new encoder that writes to w.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. It's a drop-in replacement for encoding/json.Unmarshal with better performance.

func UnmarshalFromString

func UnmarshalFromString(data string, v interface{}) error

UnmarshalFromString parses the JSON-encoded string and stores the result in the value pointed to by v. This is more efficient than string to bytes conversion followed by Unmarshal.

func Valid

func Valid(data []byte) bool

Valid reports whether data is a valid JSON encoding.

Types

This section is empty.

Jump to

Keyboard shortcuts

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