8000 GitHub - willkk/json-conf: A library that reads app's json-formatted config files and wipes out comments
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

willkk/json-conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

json-conf

A library that reads app's json-formatted config files and wipes out comments.

Features

  1. Support comments like "//" at the beginning or end of lines.
  2. Support comments like "/* ... */" in multiple lines.

Non-features

  1. Don't support Embeded comments like "/* ... /* ... */... */" in single or multiple lines.

Example

Json-formmated config file is:

{
	// all field.
	"timeout":100, // time out in http
	/*"ip":"127.0.0.1",
	"port":8000,*/
	"redis":"127.0.0.1:6379",
	"mysql":"127.0.0.1:3306"
}

Your AppConfig struct is defined as:

type MyConf struct {
	Timeout int `json:"timeout"`
	Ip string `json:"ip"`
	Port int `json:"port"`
	Redis string `json:"redis"`
	Mysql string `json:"mysql"`
	Log string `json:"log"`
}

After jsonconf.Unmarshal(), print(myConf) gets this:

{100 0 127.0.0.1:6379 127.0.0.1:3306 }

About

A library that reads app's json-formatted config files and wipes out comments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0