{"id":22682215,"url":"https://github.com/hyper-prog/smartyaml","last_synced_at":"2026-04-27T23:35:18.302Z","repository":{"id":57650577,"uuid":"447941035","full_name":"hyper-prog/smartyaml","owner":"hyper-prog","description":"SmartYAML - Go package to handle YAML","archived":false,"fork":false,"pushed_at":"2022-03-08T12:38:27.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T14:23:58.848Z","etag":null,"topics":["go","golang","json-parser","module","parser","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyper-prog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-14T11:17:30.000Z","updated_at":"2022-02-25T15:30:01.000Z","dependencies_parsed_at":"2022-09-12T06:10:58.465Z","dependency_job_id":null,"html_url":"https://github.com/hyper-prog/smartyaml","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hyper-prog/smartyaml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-prog%2Fsmartyaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-prog%2Fsmartyaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-prog%2Fsmartyaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-prog%2Fsmartyaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyper-prog","download_url":"https://codeload.github.com/hyper-prog/smartyaml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyper-prog%2Fsmartyaml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32360113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang","json-parser","module","parser","yaml"],"created_at":"2024-12-09T20:25:53.399Z","updated_at":"2026-04-27T23:35:18.288Z","avatar_url":"https://github.com/hyper-prog.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/hyper-prog/smartyaml.svg)](https://pkg.go.dev/github.com/hyper-prog/smartyaml)\n\nSmartYAML - Go package to handle YAML\n======================================\n\nThe smartyaml is a go package to handle parsed YAML files more confortable.\nThis package is not a parser, it uses the \"gopkg.in/yaml.v3\" package as parser.\nIt gives you some convenient helper functions to query/view/convert parsed YAML data structures.\n\nIn order to use it you have to get the package\n\n\tgo get github.com/hyper-prog/smartyaml\n\n*It seems that \"go get ...\" does not always work above go version 1.16. \nTo workaround this set the \"GO111MODULE=auto\" environment variable during go get.*\n\nCheck out the https://github.com/hyper-prog/smartjson package to work with JSON\n\nSample code:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hyper-prog/smartyaml\"\n)\n\nvar sampleyaml string = `\nfirstName: John\nlastName: Smith\nisAlive: Yes\nage: 27\naddress:\n  streetAddress: 21 2nd Street\n  city: New York\n  state: NY\n  postalCode: \"10021-3100\"\nphoneNumbers:\n- type: home\n  number: \"212 555-1234\"\n- type: office\n  number: \"646 555-4567\"\nchildren:\nspouse:\n`\n\nfunc main() {\n\t/* // Yaml load from file:\n\tyamlData, flerr := ioutil.ReadFile(\"test.yml\")\n\tif flerr != nil {\n\t\tfmt.Println(\"Error, cannot read file: \", flerr.Error())\n\t}\n\tsj, parsererror := smartyaml.ParseYAML(yamlData)\n\t*/\n\n\tsy, parsererror := smartyaml.ParseYAML([]byte(sampleyaml))\n\tif parsererror != nil {\n\t\tfmt.Println(\"Error, not valid YAML: \", parsererror.Error())\n\t}\n\n\tfmt.Println(\"City: \", sy.GetStringByPathWithDefault(\"$.address.city\", \"Unknown\"))\n\tfmt.Println(\"First phone number: \", sy.GetStringByPathWithDefault(\"/phoneNumbers/[0]/number\", \"Not available\"))\n\t_, agetype := sy.GetNodeByPath(\"age\")\n\tfmt.Println(\"Type of Age: \", agetype)\n\tfmt.Println(\"Json:\")\n\tfmt.Println()\n\tfmt.Println(sy.JsonIndented())\n}\n```\n\nQuery path types\n----------------\n\nYou can query the nodes like directories, separated with `/` where the root sign is optional.\n\nYou can also use JsonPath to query a value.\nJsonPath mode is automatic if the query string starts with \"$.\" or \"JsonPath:\" prefix\n\n\t/members/[0]/name - Name of the first member\n\t$.members[2]/name - Name of the third member\n\t/config/items/[]/description  - The description of the last config item\n\t$.config.server.address - The address of the configured server\n\nAvailable functions\n-------------------\n\n| Function                                         | Description                                 |\n| ------------------------------------------------ | ------------------------------------------- |\n| `ParseYAML(rawdata []byte)`                      | Parse the YAML data                         |\n| `Yaml()`                                         | Generates a YAML string                     |\n| `JsonIndented()`                                 | Generates an indented JSON string           |\n| `JsonCompacted()`                                | Generates a compacted JSON string           |\n| `NodeExists(path string)`                        | True if the given node exists               |\n| `GetCountDescendantsByPath(path string)`         | Gives the number of descendants of the node |\n| `GetNodeByPath(path string)`                     | Gives the node and node type by path        |\n| `GetStringByPath(path string)`                   | String value of the requested node          |\n| `GetNumberByPath(path string)`                   | Float or int value as float of the requested node  |\n| `GetFloat64ByPath(path string)`                  | Float value of the requested node           |\n| `GetIntegerByPath(path string)`                  | Integer value of the requested node         |\n| `GetTimeByPath(path string)`                     | Time value of the requested node            |\n| `GetBoolByPath(path string)`                     | Bool value of the requested node            |\n| `GetStringByPathWithDefault(path string, def string)`   | String value of the requested node with fallback value  |\n| `GetNumberByPathWithDefault(path string, def float64)`  | Float or int value as float of the requested node with fallback value |\n| `GetFloat64ByPathWithDefault(path string, def float64)` | Float value of the requested node with fallback value   |\n| `GetIntegerByPathWithDefault(path string, def int)`     | Integer value of the requested node with fallback value |\n| `GetTimeByPathWithDefault(path string, def time.Time)`  | Time value of the requested node with fallback value    |\n| `GetBoolByPathWithDefault(path string, def bool)`       | Bool value of the requested node with fallback value    |\n| `GetMapByPath(path string)`                      | The map on the path                         |\n| `GetArrayByPath(path string)`                    | The array on the path                       |\n| `GetSubyamlByPath(path string)`                  | Gives the sub yaml specified by path        |\n\n\nAuthor, License\n---------------\n\nThe package is written by Peter Deak (C) hyper80@gmail.com under Apache 2.0 license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper-prog%2Fsmartyaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyper-prog%2Fsmartyaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyper-prog%2Fsmartyaml/lists"}