Simple JSON configuration file parser.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 12 commits ahead, 4 commits behind stathat:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis.yml
LICENSE
Makefile
README.md
config.go
config_test.go

README.md

jconfig

Build Status Bitdeli Badge

This is a Go package to parse a configuration file using JSON.

It was ogirinally developed by Stathat but we are maintaining a fork of it here due to it being a dependency to other projects we maintain.

Installation

$ go get github.com/stathat/jconfig

Usage

import (
    "github.com/groundsix/jconfig"
)

Example

Here is our example JSON file:

{
    "name" : "Harry",
    "age"  : 22,
    "pets" : ["Dog", "Cat"]
}

And to make use of this data:

package main

import (
    "fmt"
    "github.com/groundsix/jconfig"
)

func main() {
    config := jconfig.LoadConfig("path/to/your/config.json")

    name := config.GetString("name")
    age  := config.GetInt("age")
    pets := config.GetArray("pets")

    fmt.Println(pets[0]) // Dog
}

See config.go for full API and types that can be pulled from your config file.

Running Tests

$ make test

About

Originally written by Patrick Crosby at StatHat. (@stat_hat)

Fork currently being maintained by Ground Six. (@groundsix)

License

MIT