{"id":22423331,"url":"https://github.com/prantlf/v-yaml","last_synced_at":"2025-08-01T07:32:15.616Z","repository":{"id":172958574,"uuid":"650020442","full_name":"prantlf/v-yaml","owner":"prantlf","description":"Strictly parse and format YAML data.","archived":false,"fork":false,"pushed_at":"2024-11-16T03:42:13.000Z","size":2916,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-16T04:23:41.720Z","etag":null,"topics":["vlang","vlang-package","yaml"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prantlf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T06:55:03.000Z","updated_at":"2024-11-16T03:42:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"4a22dc6a-9e77-44b0-becf-2c456171446e","html_url":"https://github.com/prantlf/v-yaml","commit_stats":null,"previous_names":["prantlf/v-yaml"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fv-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fv-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fv-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prantlf%2Fv-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prantlf","download_url":"https://codeload.github.com/prantlf/v-yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228348371,"owners_count":17905899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vlang","vlang-package","yaml"],"created_at":"2024-12-05T18:10:07.746Z","updated_at":"2025-08-01T07:32:15.607Z","avatar_url":"https://github.com/prantlf.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAML Parser and Formatter\n\nStrictly parse and format [YAML] data.\n\n* Works [fast](#performance) leveraging [libyaml] written in C.\n* Works with the `Any` type suitable for safe handling of [JSON]/[YAML] data.\n* Allows unmarshalling the [YAML] contents to a static V type.\n\nUses [prantlf.jany]. See also the [prantlf.json] package and the [yaml2json] tool.\n\n## Synopsis\n\n```go\nimport prantlf.yaml { parse_file, parse_text }\n\n// Parse text input\ninput := r'\n  answer: 42\n'\nany := parse_text(input)!\n\n// Log the Any data\nprintln(any.str()) // {answer:42}\n\n// Get a value\nconfig := any.object()!\nanswer := config['answer']!.int()!\n\n// Unmarshal a file to a V type\nstruct Config {\n\tanswer int\n}\nconfig := unmarshal_file[Config]('config.yaml')\n```\n\n## Installation\n\nYou can install this package either from [VPM] or from GitHub:\n\n```txt\nv install prantlf.yaml\nv install --git https://github.com/prantlf/v-yaml\n```\n\nYou will usually need the `Any` type as well, either from [VPM] or from GitHub:\n\n```txt\nv install prantlf.jany\nv install --git https://github.com/prantlf/v-jany\n```\n\n## API\n\nThe following functions are exported:\n\n### parse_text(input string) !Any\n\nParses an input string in the YAML format to an `Any` value. See [jany] for more information about the `Any` type.\n\n```go\ninput := r'\n  answer: 42\n'\nany := parse_text(input)!\n```\n\n### parse_file(path string) !Any\n\nLoads the contents of a text file in the YAML format and parses it to an `Any` value. See [jany] for more information about the `Any` type.\n\n```go\nany := parse_file('config.yaml')!\n```\n\n### unmarshal_text[T](input string, opts \u0026UnmarshalOpts) !T\n\nUnmarshals an input string in the YAML format to a new instance of `T`. See [jany] for more information about the `Any` type and the `UnmarshalOpts` struct.\n\n```go\nstruct Config {\n\tanswer int\n}\n\ninput := r'\n  answer: 42\n'\nconfig := unmarshal_text[Config](input, UnmarshalOpts{})!\n```\n\n### unmarshal_text_to[T](input string, mut obj T, opts \u0026UnmarshalOpts) !\n\nUnmarshals an input string in the YAML format to an existing instance of `T`. See [jany] for more information about the `Any` type and the `UnmarshalOpts` struct.\n\n```go\nstruct Config {\n\tanswer int\n}\n\ninput := r'\n  answer: 42\n'\nmut config := Config{}\nconfig := unmarshal_text_to(input, mut config, UnmarshalOpts{})!\n```\n\n### unmarshal_file[T](path string, opts \u0026UnmarshalOpts) !T\n\nLoads the contents of a text file in the YAML format and unmarshals it to a new instance of `T`. See [jany] for more information about the `Any` type and the `UnmarshalOpts` struct.\n\n```go\nstruct Config {\n\tanswer int\n}\n\nconfig := unmarshal_file[Config]('config.yaml', UnmarshalOpts{})!\n```\n\n### unmarshal_file_to[T](path string, mut obj T, opts UnmarshalOpts) !\n\nLoads the contents of a text file in the YAML format and unmarshals it to an existing instance of `T`. See [jany] for more information about the `Any` type and the `UnmarshalOpts` struct.\n\n```go\nstruct Config {\n\tanswer int\n}\n\nmut config := Config{}\nconfig := unmarshal_file_to('config.yaml', mut config, UnmarshalOpts{})!\n```\n\n## Performance\n\nThis module is only 2.6x slower than `prantlf.json` when parsing more complicated input:\n\n    ❯ ./parse_bench.vsh\n\n    SPENT   271.321 ms in parsing with prantlf.json\n    SPENT   708.940 ms in parsing with prantlf.yaml\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code.\n\n## License\n\nCopyright (c) 2023-2025 Ferdinand Prantl\n\nLicensed under the MIT license.\n\n[VPM]: https://vpm.vlang.io/packages/prantlf.yaml\n[prantlf.jany]: https://github.com/prantlf/v-jany\n[prantlf.json]: https://github.com/prantlf/v-json\n[yaml2json]: https://github.com/prantlf/v-yaml2json\n[libyaml]: https://github.com/yaml/libyaml/\n[JSON]: https://www.json.org/\n[YAML]: https://yaml.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fv-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprantlf%2Fv-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprantlf%2Fv-yaml/lists"}