yaml / libyaml

Canonical source repository for LibYAML
http://pyyaml.org/wiki/LibYAML
MIT License
951 stars 316 forks source link

Why not provide some interface like PyYaml? #243

Closed y-Adrian closed 2 years ago

y-Adrian commented 2 years ago

When I want to use C programs to process yaml file, I found it is not so convenient compared to PyYaml. Like get specific value through the key.

perlpunk commented 2 years ago

C has no native dictionaries like Python.

There is a document interface though. https://github.com/yaml/libyaml/blob/master/tests/run-loader.c#L42 yaml_parser_load(&parser, &document)

To see what you can do with such a document struct, open the documentation of libyaml (see https://github.com/yaml/libyaml/releases - fetch the tarball and look under the doc directory).

Go to "Data Structures" - "yaml_document_s"

There you will find functions like yaml_document_add_sequence, yaml_document_append_sequence_item etc.

I don't know how much C you know, but in general a lot of things are more convenient in languages like Python than they are in C :)

perlpunk commented 2 years ago

You might also want to try https://github.com/pantoniou/libfyaml as it has a nice commandline tool with support to reference paths in the structure

y-Adrian commented 2 years ago

Thank you! @perlpunk