jsonl

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 3 Imported by: 1

README

jsonl

This package provides support for reading JSON Lines format.

Examples

package main

import (
	"fmt"
	"os"

	"github.com/mithrandie/go-text/json"
	"github.com/mithrandie/go-text/jsonl"
)

func main() {
	fp, err := os.Open("example.jsonl")
	if err != nil {
		panic("file open error")
	}
	defer func() {
		if err = fp.Close(); err != nil {
			panic(err.Error())
		}
	}()

	r := jsonl.NewReader(fp)
	structures, escapeType, err := r.ReadAll()

	fmt.Printf("Escape Type: %v\n", escapeType)

	e := json.NewEncoder()
	e.EscapeType = escapeType

	for _, st := range structures {
		fmt.Println(e.Encode(st))
    }
}

Documentation

Overview

Package jsonl is a Go library to read and write JSON Lines format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Pos

func (r *Reader) Pos() int

func (*Reader) Read

func (r *Reader) Read() (json.Structure, json.EscapeType, error)

func (*Reader) ReadAll

func (r *Reader) ReadAll() ([]json.Structure, json.EscapeType, error)

func (*Reader) SetUseInteger

func (r *Reader) SetUseInteger(useInteger bool)

Jump to

Keyboard shortcuts

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