Documentation

Overview

    Package gparser provides convenient API for accessing/converting variable and JSON/XML/YAML/TOML.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func MustToIni

    func MustToIni(value interface{}) []byte

    func MustToIniString

    func MustToIniString(value interface{}) string

    func MustToJson

    func MustToJson(value interface{}) []byte

    func MustToJsonIndent

    func MustToJsonIndent(value interface{}) []byte

    func MustToJsonIndentString

    func MustToJsonIndentString(value interface{}) string

    func MustToJsonString

    func MustToJsonString(value interface{}) string

    func MustToToml

    func MustToToml(value interface{}) []byte

    func MustToTomlString

    func MustToTomlString(value interface{}) string

    func MustToXml

    func MustToXml(value interface{}, rootTag ...string) []byte

    func MustToXmlIndent

    func MustToXmlIndent(value interface{}, rootTag ...string) []byte

    func MustToXmlIndentString

    func MustToXmlIndentString(value interface{}, rootTag ...string) string

    func MustToXmlString

    func MustToXmlString(value interface{}, rootTag ...string) string

    func MustToYaml

    func MustToYaml(value interface{}) []byte

    func MustToYamlString

    func MustToYamlString(value interface{}) string

    func VarToIni

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

    func VarToIniString

    func VarToIniString(value interface{}) (string, error)

    func VarToJson

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

    func VarToJsonIndent

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

    func VarToJsonIndentString

    func VarToJsonIndentString(value interface{}) (string, error)

    func VarToJsonString

    func VarToJsonString(value interface{}) (string, error)

    func VarToToml

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

    func VarToTomlString

    func VarToTomlString(value interface{}) (string, error)

    func VarToXml

    func VarToXml(value interface{}, rootTag ...string) ([]byte, error)

    func VarToXmlIndent

    func VarToXmlIndent(value interface{}, rootTag ...string) ([]byte, error)

    func VarToXmlIndentString

    func VarToXmlIndentString(value interface{}, rootTag ...string) (string, error)

    func VarToXmlString

    func VarToXmlString(value interface{}, rootTag ...string) (string, error)

    func VarToYaml

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

    func VarToYamlString

    func VarToYamlString(value interface{}) (string, error)

    Types

    type Parser

    type Parser = gjson.Json

      Parser is actually alias of gjson.Json.

      func Load

      func Load(path string, safe ...bool) (*Parser, error)

        Load loads content from specified file <path>, and creates a Parser object from its content.

        func LoadContent

        func LoadContent(data interface{}, safe ...bool) (*Parser, error)

          LoadContent creates a Parser object from given content, it checks the data type of <content> automatically, supporting JSON, XML, INI, YAML and TOML types of data.

          func LoadIni

          func LoadIni(data interface{}, safe ...bool) (*Parser, error)

          func LoadJson

          func LoadJson(data interface{}, safe ...bool) (*Parser, error)

          func LoadToml

          func LoadToml(data interface{}, safe ...bool) (*Parser, error)

          func LoadXml

          func LoadXml(data interface{}, safe ...bool) (*Parser, error)

          func LoadYaml

          func LoadYaml(data interface{}, safe ...bool) (*Parser, error)

          func New

          func New(data interface{}, safe ...bool) *Parser

            New creates a Parser object with any variable type of <data>, but <data> should be a map, struct or slice for data access reason, or it will make no sense.

            The parameter <safe> specifies whether using this Json object in concurrent-safe context, which is false in default.

            func NewWithTag

            func NewWithTag(data interface{}, tags string, safe ...bool) *Parser

              NewWithTag creates a Parser object with any variable type of <data>, but <data> should be a map or slice for data access reason, or it will make no sense.

              The parameter <tags> specifies priority tags for struct conversion to map, multiple tags joined with char ','.

              The parameter <safe> specifies whether using this Json object in concurrent-safe context, which is false in default.