json

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyPolicy

type EmptyPolicy int

EmptyPolicy defines the behavior when adding an empty string

const (
	// OmitEmpty does not write the field if the string is empty
	OmitEmpty EmptyPolicy = iota

	// AllowEmpty writes the string even if the string is empty
	AllowEmpty
)

type RawObjectWriter

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

RawObjectWriter contains helper functions to write JSON using the raw API.

func NewRawObjectWriter

func NewRawObjectWriter(stream *jsoniter.Stream) *RawObjectWriter

NewRawObjectWriter creates a new instance of RawObjectWriter

func (*RawObjectWriter) AddInt64Field

func (writer *RawObjectWriter) AddInt64Field(fieldName string, value int64)

AddInt64Field adds a new field of type int64

func (*RawObjectWriter) AddStringField

func (writer *RawObjectWriter) AddStringField(fieldName string, value string, policy EmptyPolicy)

AddStringField adds a new field of type string

func (*RawObjectWriter) AddStringValue

func (writer *RawObjectWriter) AddStringValue(value string)

AddStringValue adds a string (for example inside an array)

func (*RawObjectWriter) FinishArrayField

func (writer *RawObjectWriter) FinishArrayField() error

FinishArrayField finishes an array field

func (*RawObjectWriter) FinishObject

func (writer *RawObjectWriter) FinishObject() error

FinishObject finishes a JSON object (add '}')

func (*RawObjectWriter) Flush

func (writer *RawObjectWriter) Flush() error

Flush the stream

func (*RawObjectWriter) StartArrayField

func (writer *RawObjectWriter) StartArrayField(fieldName string) error

StartArrayField starts a new field of type array

func (*RawObjectWriter) StartObject

func (writer *RawObjectWriter) StartObject() error

StartObject starts a new JSON object (add '{')

Jump to

Keyboard shortcuts

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