usox/hacore

以严格模式读取 json 配置

安装: 844

依赖: 0

建议者: 0

安全性: 0

星标: 2

关注者: 3

分支: 0

开放问题: 0

语言:Shell

v1.3.0 2019-02-15 07:21 UTC

This package is auto-updated.

Last update: 2024-09-15 19:24:56 UTC


README

Build Status

Hacore - Hack 配置读取器

Hacore 提供了一种简单的方法来以 Hack 严格模式读取格式为 json 的配置文件。

示例配置

Hacore 将所有配置值视为字符串并会显式转换。要访问单个键的值,只需使用 getLeaf($key_name)。要获取完整的选项分支,使用 getBranch($key_name)

{
	"foo":"bar",
	"barfoo":666,
	"more":{
		"config":"options"
	}
}
$reader = new \Usox\Hacore\Reader();
$reader->load('path-to-config.json')

$reader->getLeaf('foo'); // returns 'bar'
$reader->getLeaf('barfoo'); // returns '666'
$reader->getBranch('more'); // returns a new Reader instance