0

I would like to represent the following JSON structure in YAML.

[ 
    {'text': 'Text1', 'url': 'Url1'},
    {'text': 'Text2', 'url': 'Url2'},
    {'text': 'Text3', 'url': 'Url3'},
]

I have tried without success:

-
    text: Text1
    url: Url1
-
    text: Text2
    url: Url2
-
    text: Text3
    url: Url3

In case it might be relevant, the structure is going to be used in Grav/Twig, although I think it is a pure YAML issue.

4

1 回答 1

1

Grav 现在为 yaml-encoding 和 yaml-decoding 提供了两个新的过滤器。示例用法:{{ page.header.myarray|yaml_encode }}

根据此提交,这些过滤器将在即将发布的 1.4 版本中提供:https ://github.com/getgrav/grav/commit/c721be8787b09aab1dce6bd012c8d43d1a985558

希望能帮助到你

于 2018-02-05T09:44:11.023 回答