parsers

package
v0.0.0-...-8aeb8a1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValueIsNil = errors.New("value is nil")

Functions

func ParseCsv

func ParseCsv(r io.Reader, typeConverts map[string]func(interface{}) (interface{}, error)) ([]map[string]interface{}, error)

ParseCsv return objects with formatted keys: toLower and replaced all spaces with underscore cast types

func ParseInterface

func ParseInterface(v interface{}) (map[string]interface{}, error)

ParseInterface converts interface into json bytes then into map with json Numbers

func ParseJSON

func ParseJSON(b []byte) (map[string]interface{}, error)

ParseJSON converts json bytes into map with json Numbers removes first empty bytes if exist

func ParseJSONAsFile

func ParseJSONAsFile(newPath string, value interface{}) (string, error)

ParseJSONAsFile parses value and write it to a json file returns path to created json file or return value if it is already path to json file or empty string if value is nil

func ParseJSONAsObject

func ParseJSONAsObject(b []byte, value interface{}) error

ParseJSONAsObject converts json bytes into the object removes first empty bytes if exist

func ParseJSONFile

func ParseJSONFile(b []byte) ([]map[string]interface{}, error)

ParseJSONFile converts bytes (JSON objects with \n delimiter) into slice of map with json Numbers

func ParseJSONFileWithFunc

func ParseJSONFileWithFunc(b []byte, parseFunc func(b []byte) (map[string]interface{}, error)) ([]map[string]interface{}, error)

ParseJSONFileWithFunc converts bytes (JSON objects with \n delimiter) into slice of map with json Numbers failfast: returns err if at least 1 occurred

func RemoveFirstEmptyBytes

func RemoveFirstEmptyBytes(b []byte) []byte

RemoveFirstEmptyBytes checks if array contains empty bytes in the begging and removes them

Types

type ParseError

type ParseError struct {
	Original []byte
	Error    string
}

func ParseJSONBytesWithFuncFallback

func ParseJSONBytesWithFuncFallback(b []byte, parseFunc func(b []byte) (map[string]interface{}, error)) ([]map[string]interface{}, []ParseError, error)

ParseJSONBytesWithFuncFallback converts bytes (JSON objects with \n delimiter) into slice of map with json Numbers returns slice with events and slice with parsing errors which contains malformed JSON's(malformed lines)

func ParseJSONFileWithFuncFallback

func ParseJSONFileWithFuncFallback(r io.Reader, parseFunc func(b []byte) (map[string]interface{}, error)) ([]map[string]interface{}, []ParseError, error)

ParseJSONFileWithFuncFallback converts bytes (JSON objects with \n delimiter) into slice of map with json Numbers returns slice with events and slice with parsing errors which contains malformed JSON's(malformed lines)

Jump to

Keyboard shortcuts

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