go-json-pointer is a utility library to read JSON properties easily
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
config
pkg
.gitignore
ChangeLog
LICENSE
Makefile
README.md
setup
tdd

README.md

go-config

go-config is a utility library to access JSON based configuration easily. Go language supports JSON format in the standard library. However, I feel that the standard library is not useful to parse any JSON formats [1] [2].

For that reason, I have developed the open source package to access JSON properties easily. Using go-config, you can get the JSON properties in the specified JSON file or string by the given path like XPath for XML specification.

Finally, I will support RFC 6901, JSON Pointer, [3] specification.

Using go-config, you can read JSON easily as the following.

Using Config, you can read a configuration file based on JSON easily. The sample configuration is bellow.

	config, err := NewConfig()
	if err != nil {
		t.Error(err)
	}

	err = config.ParseFromFile("/etc/profile.conf")
	if err != nil {
		t.Error(err)
	}

	name, err := config.GetKeyStringByPath("/organizer/name")
	if err != nil {
		t.Error(err)
	}

	age, err := config.GetKeyStringByPath("/organizer/age")
	if err != nil {
		t.Error(err)
	}
  • /etc/profile.conf
#
#  /etc/profile.conf
#

{
	"organizer": {
		"name": "John Smith",
		"age": 33
	}
}

Repository

Documents

Please check the godoc as the following.

godoc -http=:6060

References