confjson

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 3 Imported by: 0

README

conf-parser-json

Code Analysis Go Reference codecov GitHub tag (latest SemVer)

The conf parser to JSON format.

License

MIT licensed. See the bundled LICENSE file for more details.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parser

func Parser(_ context.Context, r io.Reader) (interface{}, error)

Parser is a conf.ParseFunc to parse the given json

Example
package main

import (
	"context"
	"fmt"
	"strings"

	"github.com/sv-tools/conf"

	confjson "github.com/sv-tools/conf-parser-json"
)

func main() {
	data := strings.NewReader(`{"foo": 42, "bar": "test"}`)
	c := conf.New().WithReaders(conf.NewStreamParser(data).WithParser(confjson.Parser))
	if err := c.Load(context.Background()); err != nil {
		panic(err)
	}

	fmt.Println(c.GetInt("foo"))
}
Output:

42

Types

This section is empty.

Jump to

Keyboard shortcuts

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