parse

package
v0.0.0-...-02bf512 Latest Latest
Warning

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

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

Documentation

Overview

Package parse is a streaming parser for JSON objects

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Iterate

func Iterate(src io.Reader) iter.Iter[json.Value]

Iterate parses a JSON document into an iter[json.Value]. If the document is an object, the object is parsed completely before returning it as an iter of one element. If the document is an array, the array top level elements are parsed as the returnd iter is iterated.

Useful for cases like writing JSON data to a database, where the JSON input could contain a large number of records, and it is preferable to store each record one at a time, or perhaps in batches of some fixed maximum size.

func MustParse

func MustParse(src io.Reader) json.Value

MustParse is a must version of Parse

func Parse

func Parse(src io.Reader) (json.Value, error)

Parse parses a JSON document fully before returning it, unlike Iterate which provides an iter. Useful for cases like a configuration file, where you need the whole document, and it is easier to not have to iterate. The top level object or array is provided as a Value. If the reader can be parsed into a valid json document the result is (Value, nil), else it is (invalid value, error).

Types

This section is empty.

Jump to

Keyboard shortcuts

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