XUtils

lyaml

YAML encoding/decoding via binding to LibYAML.


lyaml.dump

lyaml.dump accepts a table of values to dump. Each value in the table represents a single YAML document. To dump a table of lua values this means the table must be wrapped in another table (the outer table represents the YAML documents, the inner table is the single document table to dump).

lyaml.dump({ { foo = "bar" } })
--> ---
--> foo: bar
--> ...

lyaml.dump({ "one", "two" })
--> --- one
--> ...
--> --- two
--> ...

If you need to round-trip load a dumped document, and you used a custom function for converting implicit scalars, then you should pass that same function in the implicit_scalar field of the OPTS-TABLE argument to lyaml.dump so that it can quote strings that might otherwise be implicitly converted on reload.


Articles

  • coming soon...