{"id":21560400,"url":"https://github.com/icza/dyno","last_synced_at":"2025-04-04T22:07:23.475Z","repository":{"id":40589211,"uuid":"114658174","full_name":"icza/dyno","owner":"icza","description":"Package dyno is a utility to work with dynamic objects at ease.","archived":false,"fork":false,"pushed_at":"2023-03-30T12:59:55.000Z","size":57,"stargazers_count":133,"open_issues_count":0,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T21:06:44.230Z","etag":null,"topics":["array","dictionary","dynamic-objects","map","path","slice"],"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/icza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"icza"}},"created_at":"2017-12-18T15:40:34.000Z","updated_at":"2024-12-06T22:23:28.000Z","dependencies_parsed_at":"2024-06-18T13:43:06.823Z","dependency_job_id":"59a77552-382b-43e7-bbac-4306366c27e3","html_url":"https://github.com/icza/dyno","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fdyno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fdyno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fdyno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fdyno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icza","download_url":"https://codeload.github.com/icza/dyno/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256112,"owners_count":20909240,"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":["array","dictionary","dynamic-objects","map","path","slice"],"created_at":"2024-11-24T09:14:07.481Z","updated_at":"2025-04-04T22:07:23.458Z","avatar_url":"https://github.com/icza.png","language":"Go","readme":"# dyno\n\n![Build Status](https://github.com/icza/dyno/actions/workflows/go.yml/badge.svg)\n[![Go Reference](https://pkg.go.dev/badge/github.com/icza/dyno.svg)](https://pkg.go.dev/github.com/icza/dyno)\n[![Go Report Card](https://goreportcard.com/badge/github.com/icza/dyno)](https://goreportcard.com/report/github.com/icza/dyno)\n[![codecov](https://codecov.io/gh/icza/dyno/branch/master/graph/badge.svg)](https://codecov.io/gh/icza/dyno)\n\nPackage dyno is a utility to work with _dynamic objects_ at ease.\n\nPrimary goal is to easily handle dynamic objects and arrays (and a mixture of these)\nthat are the result of unmarshaling a JSON or YAML text into an `interface{}`\nfor example. When unmarshaling into `interface{}`, libraries usually choose\neither `map[string]interface{}` or `map[interface{}]interface{}` to represent objects,\nand `[]interface{}` to represent arrays. Package dyno supports a mixture of\nthese in any depth and combination.\n\nWhen operating on a dynamic object, you designate a value you're interested\nin by specifying a _path_. A path is a _navigation_; it is a series of map keys\nand `int` slice indices that tells how to get to the value.\n\nShould you need to marshal a dynamic object to JSON which contains maps with\n`interface{}` key type (which is not supported by `encoding/json`), you may use\nthe `ConvertMapI2MapS` converter function.\n\nThe implementation does not use reflection at all, so performance is rather good.\n\n### Supported Operations\n\n- Get a (typed) value denoted by a path: [Get](https://godoc.org/github.com/icza/dyno#Get), [GetInt](https://godoc.org/github.com/icza/dyno#GetInt),  [GetString](https://godoc.org/github.com/icza/dyno#GetString), [GetSlice](https://godoc.org/github.com/icza/dyno#GetSlice), [GetMapI](https://godoc.org/github.com/icza/dyno#GetMapI), [GetMapS](https://godoc.org/github.com/icza/dyno#GetMapS)\n\n- Get a typed value with built-in conversion / parsing: [GetInteger](https://godoc.org/github.com/icza/dyno#GetInteger), [GetFloating](https://godoc.org/github.com/icza/dyno#GetFloating), [GetBoolean](https://godoc.org/github.com/icza/dyno#GetBoolean)\n\n- Specialized get for maps with `string` keys: [SGet](https://godoc.org/github.com/icza/dyno#SGet)\n\n- Set a value denoted by a path: [Set](https://godoc.org/github.com/icza/dyno#Set)\n\n- Specialized set for maps with `string` keys: [SSet](https://godoc.org/github.com/icza/dyno#SSet)\n\n- Append value(s) to a slice denoted by a path: [Append](https://godoc.org/github.com/icza/dyno#Append), [AppendMore](https://godoc.org/github.com/icza/dyno#AppendMore)\n\n- Delete a key from a map or an element from a slice denoted by a path: [Delete](https://godoc.org/github.com/icza/dyno#Delete)\n\n- Convert maps with `interface{}` keys to maps with `string` keys: [ConvertMapI2MapS](https://godoc.org/github.com/icza/dyno#ConvertMapI2MapS)\n\n### Example\n\nLet's see a simple example editing a JSON text to mask out a password. This is\na simplified version of the [`Example_jsonEdit`](https://godoc.org/github.com/icza/dyno#example-package--JsonEdit) example function:\n\n\tsrc := `{\"login\":{\"password\":\"secret\",\"user\":\"bob\"},\"name\":\"cmpA\"}`\n\tvar v interface{}\n\tif err := json.Unmarshal([]byte(src), \u0026v); err != nil {\n\t\tpanic(err)\n\t}\n\t// Edit (mask out) password:\n\tif err = dyno.Set(v, \"xxx\", \"login\", \"password\"); err != nil {\n\t\tfmt.Printf(\"Failed to set password: %v\\n\", err)\n\t}\n\tedited, err := json.Marshal(v)\n\tfmt.Printf(\"Edited JSON: %s, error: %v\\n\", edited, err)\n\nOutput will be:\n\n\tEdited JSON: {\"login\":{\"password\":\"xxx\",\"user\":\"bob\"},\"name\":\"cmpA\"}, error: \u003cnil\u003e\n","funding_links":["https://github.com/sponsors/icza"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficza%2Fdyno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficza%2Fdyno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficza%2Fdyno/lists"}