Skip to content

Question: how do I use the omap tag? #14

Open

Description

@kalekje

For example,

yaml = require`tinyyaml`
doc = [[
t: !!omap
  a: 1
  b: 2
  c: 3
  d: 4
]]

t = yaml.parse(doc).t

for k, v in pairs(t) do
    print(k, v)
end

does not guarantee order. Is there a different iteration function I can use?

Activity

  1. spacewander commented on Oct 8, 2021

    @spacewander

    The omap should be array type:

    # Explicitly typed ordered map (dictionary).
    Bestiary: !!omap
      - aardvark: African pig-like ant eater. Ugly.
      - anteater: South-American ant eater. Two species.
      - anaconda: South-American constrictor snake. Scaly.
    

    See https://yaml.org/type/omap.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions