Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kalekje opened this issue Oct 7, 2021 · 1 comment
Open

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

kalekje opened this issue Oct 7, 2021 · 1 comment

Comments

@kalekje
Copy link

kalekje commented Oct 7, 2021

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?

@spacewander
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants