{"id":21500698,"url":"https://github.com/lost22git/dig","last_synced_at":"2025-07-25T07:33:29.890Z","repository":{"id":229470359,"uuid":"776826168","full_name":"lost22git/dig","owner":"lost22git","description":"Parse path expr as dynamic.Decoder","archived":false,"fork":false,"pushed_at":"2024-04-17T16:33:18.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T13:18:31.325Z","etag":null,"topics":["decoder","gleam","gleam-lang","json","path-expressions"],"latest_commit_sha":null,"homepage":"","language":"Gleam","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/lost22git.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-24T14:59:03.000Z","updated_at":"2024-06-27T04:27:30.000Z","dependencies_parsed_at":"2024-03-28T12:29:17.114Z","dependency_job_id":null,"html_url":"https://github.com/lost22git/dig","commit_stats":null,"previous_names":["lost22git/dig"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lost22git/dig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lost22git%2Fdig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lost22git%2Fdig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lost22git%2Fdig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lost22git%2Fdig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lost22git","download_url":"https://codeload.github.com/lost22git/dig/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lost22git%2Fdig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266973069,"owners_count":24014614,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["decoder","gleam","gleam-lang","json","path-expressions"],"created_at":"2024-11-23T17:43:34.996Z","updated_at":"2025-07-25T07:33:29.842Z","avatar_url":"https://github.com/lost22git.png","language":"Gleam","readme":"# dig\n\n[![Package Version](https://img.shields.io/hexpm/v/dig?color=92DCE5)](https://hex.pm/packages/dig)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3?color=FCC0D2)](https://hexdocs.pm/dig/)\n\n✨ Parse path expression as [dynamic.Decoder](https://hexdocs.pm/gleam_stdlib/gleam/dynamic.html#Decoder)\n\n## Installation\n\nTo add this package to your Gleam project:\n\n```sh\ngleam add dig\n```\n\n## Usage\n\n```gleam\nimport gleeunit\nimport gleeunit/should\nimport dig\nimport gleam/option.{None, Some}\nimport gleam/json\nimport gleam/dynamic\nimport gleam/string\nimport gleam/list\nimport gleam/io\n\npub fn dig_test() {\n  let json_str =\n    \"\n  {\n    \\\"foo\\\": [\n      {\n        \\\"bar\\\": [\n          {\n            \\\"baz\\\": \\\"a\\\"\n          },\n          {\n            \\\"baz\\\": \\\"b\\\"\n          }\n        ]\n      },\n      {\n        \\\"bar\\\": [\n           {\n            \\\"baz\\\": \\\"c\\\"\n          },\n          {\n            \\\"baz\\\": \\\"d\\\"\n          }\n        ]\n      }\n    ],\n    \\\"haha\\\": {\n      \\\"meme\\\": 1\n    }\n  }\n  \"\n\n  {\n    let assert Ok(dig.DigObject(path, decoder)) =\n      dig.dig(\n        \"foo[1].bar[1].baz\"\n        |\u003e string.split(\".\"),\n      )\n\n    should.equal(path, [\"foo[1]\", \"bar[1]\", \"baz\"])\n\n    let assert Ok(d) =\n      json_str\n      |\u003e json.decode(decoder)\n\n    d\n    |\u003e dynamic.string()\n    |\u003e should.equal(Ok(\"d\"))\n  }\n\n  {\n    let assert Ok(dig.DigList(path, decoder)) =\n      dig.dig(\n        \"foo[].bar[].baz\"\n        |\u003e string.split(\".\"),\n      )\n\n    should.equal(path, [\"foo[]\", \"bar[]\", \"baz\"])\n\n    let assert Ok(d) =\n      json_str\n      |\u003e json.decode(decoder)\n\n    d\n    |\u003e list.map(dynamic.string)\n    |\u003e should.equal([Ok(\"a\"), Ok(\"b\"), Ok(\"c\"), Ok(\"d\")])\n  }\n\n  {\n    let assert Ok(dig.DigList(path, decoder)) =\n      dig.dig(\n        \"foo[].miss_me[1].baz\"\n        |\u003e string.split(\".\"),\n      )\n\n    should.equal(path, [\"foo[]\", \"miss_me[1]\", \"baz\"])\n\n    let r =\n      json_str\n      |\u003e json.decode(decoder)\n\n    case r {\n      Ok(_) -\u003e should.fail()\n      Error(errors) -\u003e {\n        io.debug(errors)\n        Nil\n      }\n    }\n  }\n}\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flost22git%2Fdig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flost22git%2Fdig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flost22git%2Fdig/lists"}