Nested lists in yaml

后端 未结 3 944
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 19:28

How can I create nested lists in YAML? I want to get:

 {\"Hello\": [\"as\", [\"http://\", [\"cat\"]]]}

Here\'s my YAML that doesn\'t work (

相关标签:
3条回答
  • 2021-01-03 19:45

    And the answer is:

    URL:
      Description: URL of the website
      Value:
        "Fn::Join":
          - ""
          - - "http://"
            - "Fn::GetAtt":
                - ElasticLoadBalancer
                - DNSName
    

    (see http://pyyaml.org/wiki/PyYAMLDocumentation#YAMLsyntax - "block sequences can be nested")

    0 讨论(0)
  • Try:

    Hello: 
      ["as", 
        ["http://", 
          [cat]
        ]
    ]
    

    Json output:

    {
      "Hello": [
        "as", 
        [
          "http://", 
          [
            "cat"
          ]
        ]
      ]
    }
    
    0 讨论(0)
  • 2021-01-03 19:51

    start nested list from a new line. using this approach it is easy to figure out.

    Read this and this articles. They have a lot of examples.

    try like this:

    YAML

    Value:
        "Fn::Join":
          - ""
          -
             - "http://"
             - "Fn::GetAtt":
                  - ElasticLoadBalancer
                  - DNSName
    

    Equivalent JSON

    {
      "URL": {
        "Description": "URL of the website",
        "Value": {
          "Fn::Join": [
            "",
            [
              "http://",
              {
                "Fn::GetAtt": [
                  "ElasticLoadBalancer",
                  "DNSName"
                ]
              }
            ]
          ]
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题