parsers

package
v4.0.0-pre-2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package parsers has internal parsers for various formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(args ...string) ([][]string, error)

CSV - Unmarshal CSV parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
   in - the CSV-format string to parse

returns:

an array of rows, which are arrays of cells (strings)

func CSVByColumn

func CSVByColumn(args ...string) (cols map[string][]string, err error)

CSVByColumn - Unmarshal CSV in a Columnar form parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
  hdr - (optional) list of column names separated by `delim`,
        set to "" to get auto-named columns (A-Z), omit
        to use the first line
   in - the CSV-format string to parse

returns:

a map of columns, indexed by the header name. values are arrays of strings

func CSVByRow

func CSVByRow(args ...string) (rows []map[string]string, err error)

CSVByRow - Unmarshal CSV in a row-oriented form parameters:

delim - (optional) the (single-character!) field delimiter, defaults to ","
  hdr - (optional) list of column names separated by `delim`,
        set to "" to get auto-named columns (A-Z), omit
        to use the first line
   in - the CSV-format string to parse

returns:

an array of rows, indexed by the header name

func CUE

func CUE(in string) (interface{}, error)

CUE - Unmarshal a CUE expression into the appropriate type

func DotEnv

func DotEnv(in string) (interface{}, error)

DotEnv - Unmarshal a dotenv file

func JSON

func JSON(in string) (map[string]interface{}, error)

JSON - Unmarshal a JSON Object. Can be ejson-encrypted.

func JSONArray

func JSONArray(in string) ([]interface{}, error)

JSONArray - Unmarshal a JSON Array

func ParseData

func ParseData(mimeType, s string) (out any, err error)

func TOML

func TOML(in string) (interface{}, error)

TOML - Unmarshal a TOML Object

func ToCSV

func ToCSV(args ...interface{}) (string, error)

ToCSV -

func ToCUE

func ToCUE(in interface{}) (string, error)

func ToJSON

func ToJSON(in interface{}) (string, error)

ToJSON - Stringify a struct as JSON

func ToJSONPretty

func ToJSONPretty(indent string, in interface{}) (string, error)

ToJSONPretty - Stringify a struct as JSON (indented)

func ToTOML

func ToTOML(in interface{}) (string, error)

ToTOML - Stringify a struct as TOML

func ToYAML

func ToYAML(in interface{}) (string, error)

ToYAML - Stringify a struct as YAML

func YAML

func YAML(in string) (map[string]interface{}, error)

YAML - Unmarshal a YAML Object

func YAMLArray

func YAMLArray(in string) ([]interface{}, error)

YAMLArray - Unmarshal a YAML Array

Types

This section is empty.

Jump to

Keyboard shortcuts

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