【发布时间】:2012-12-20 21:26:35
【问题描述】:
我尝试使用 SPYC (https://github.com/mustangostang/spyc/) 解析以下 YAML:
children:
- root:
- child one
- child two:
- subchild one
- subchild two
- child three
我希望它返回如下内容:
["children"]=>array(1){
["root"]=>array(3){
[0]=>string(9) "child one",
["child two"]=>array(2){
[0]=>string(12) "subchild one"
[1]=>string(12) "subchild two"
}
[1]=>string(11) "child three"
}
}
相反,它会返回类似这样的内容(包含似乎是一堆空且不必要的数组):
array(4) {
[0]=>
array(4) {
["root"]=>
array(0) {
}
[0]=>
string(9) "child one"
[1]=>
array(3) {
["child two"]=>
array(0) {
}
[0]=>
string(12) "subchild one"
[1]=>
string(12) "subchild two"
}
[2]=>
string(11) "child three"
}
我构建 YAML 内容的方式是否有问题,或者 SPYC(解析器)是否存在已知问题?
谢谢!
【问题讨论】: