mario-deluna / hip
极简单的人性化数据序列化。
1.0.0
2015-01-23 18:25 UTC
This package is auto-updated.
Last update: 2024-09-12 08:10:36 UTC
README
Human Input / 简单的人性化数据标记。
name: "Hip" type: "Markup language" version: 1.0 tags: "markup", "serialization", "language"
Hip 并不试图取代任何数据标记或创建一个新标准。Hip 的目标是使非技术人员可读和可写,无需解释语法。
常见问题解答
- 为什么我应该使用这个?抱歉,我不知道...这个数据解析器是一个实验,可能将被集成到 ClanCatsFramework 2.1 中。如果你正在寻找一个经过批准和稳定的序列化格式,请使用YAML。如果你认为 Hip 可能是有用的,请随时使用,每个用户都会让我感到高兴 :)
安装
这个 Hip 解析器是用 PHP 编写的,使用 PSR-4 自动加载,你可以使用 composer 来安装它。
"require":
{
"mario-deluna/hip": "dev-master"
}
用法
编码/解码
解码 hip 数据字符串为数组
Hip\Hip::decode( $hipString );
将数组编码为 hip 数据字符串
Hip\Hip::decode( $myArray );
读取/写入文件
读取 hip 文件
Hip\Hip::read( 'my/path/to/file.hip' );
写入 hip 文件
Hip\Hip::write( 'my/path/to/file.hip', $myArray );
Hip 语法
简单的键值
name: "Zaphod beeblebrox" job: "President of the Galaxy"
等于
{ "name": "Zaphod beeblebrox", "job": "President of the Galaxy" }
多层
recipe: duration: 60 ingredients: "eggs", "bacon", "cream", "leek"
等于
{ "recipe": { "duration": 60, "ingredients": [ "eggs", "bacon", "cream", "leek" ] } }
数组列表
instruments: - name: "Guitar" strings: 6 -- name: "Bass" strings: 4 -
等于
{ "instruments": [ { "name": "Guitar", "strings": 6 }, { "name": "Bass", "strings": 4 } ] }
数据类型
string: "Hello World" integer: 42 float: 3.14 yepBool: yes nopeBool: no nothing: nil
等于
{ "string": "Hello World", "integer": 42, "float": 3.14, "yepBool": true, "nopeBool": false, "nothing": null }
待办事项
- Hip 配置对象/实用工具
- 自动检测级别指示符(空格、制表符等)
- 更多测试...