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.

M.E.
  • 4,955
  • 4
  • 49
  • 128
  • What does "without success" mean? How do you process this YAML file? And what made you think its format is not right? – xabbuh Jan 29 '18 at 16:12

1 Answers1

1

Grav now provide two new filters for yaml-encoding and yaml-decoding. Example usage: {{ page.header.myarray|yaml_encode }}

These filters will be available in the upcoming 1.4 release as per this commit: https://github.com/getgrav/grav/commit/c721be8787b09aab1dce6bd012c8d43d1a985558

Hope it helps

Paul Massendari
  • 417
  • 3
  • 6