An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/icza/dyno

Package dyno is a utility to work with dynamic objects at ease. Primary goal is to easily handle dynamic objects and arrays (and a mixture of these) that are the result of unmarshaling a JSON or YAML text into an interface{} for example. When unmarshaling into interface{}, libraries usually choose either map[string]interface{} or map[interface{}]interface{} to represent objects, and []interface{} to represent arrays. Package dyno supports a mixture of these in any depth and combination. When operating on a dynamic object, you designate a value you're interested in by specifying a path. A path is a navigation; it is a series of map keys and int slice indices that tells how to get to the value. Should you need to marshal a dynamic object to JSON which contains maps with interface{} key type (which is not supported by encoding/json), you may use the ConvertMapI2MapS converter function. The implementation does not use reflection at all, so performance is rather good. Let's see a simple example editing a JSON text to mask out a password. This is a simplified version of the Example_jsonEdit example function: Output will be: Example shows a few of dyno's features, such as getting, setting and appending values to / from a dynamic object. Example_jsonEdit shows a simple example how JSON can be edited. The password placed in the JSON is masked out.
3 versions
Latest release: over 2 years ago
134 dependent packages

View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/github.com/icza/dyno

Dependent Repos 0