All Projects → icza → Dyno

icza / Dyno

Licence: apache-2.0
Package dyno is a utility to work with dynamic objects at ease.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Dyno

array-keyed-map
JS datastructure, like Map, but the keys are arrays
Stars: ✭ 29 (-64.2%)
Mutual labels:  map, array, path
Kind Of
Get the native JavaScript type of a value, fast. Used by superstruct, micromatch and many others!
Stars: ✭ 268 (+230.86%)
Mutual labels:  array, map
php-collections
A collection library for php
Stars: ✭ 34 (-58.02%)
Mutual labels:  map, array
Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (+296.3%)
Mutual labels:  dictionary, array
Core
Elm's core libraries
Stars: ✭ 2,634 (+3151.85%)
Mutual labels:  dictionary, array
Collectable
High-performance immutable data structures for modern JavaScript and TypeScript applications. Functional interfaces, deep/composite operations API, mixed mutability API, TypeScript definitions, ES2015 module exports.
Stars: ✭ 233 (+187.65%)
Mutual labels:  dictionary, map
ustd
Micro-standard-library providing minimal and portable array, queue and map for attiny avr, arduinos, esp8266/32 and linux, mac
Stars: ✭ 14 (-82.72%)
Mutual labels:  map, array
Map
PHP Map package for easy and elegant handling of PHP arrays as array-like map objects
Stars: ✭ 1,180 (+1356.79%)
Mutual labels:  array, map
Kakajson
Fast conversion between JSON and model in Swift.
Stars: ✭ 867 (+970.37%)
Mutual labels:  dictionary, array
Collection
A PHP library for representing and manipulating collections.
Stars: ✭ 488 (+502.47%)
Mutual labels:  array, map
Csmodel
CSModel is a concise and efficient model framework for iOS/OSX, and provides nested Model to compare values and copy values.
Stars: ✭ 192 (+137.04%)
Mutual labels:  dictionary, array
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+1292.59%)
Mutual labels:  dictionary, map
Redux Data Structures
Reducer factory functions for common data structures: counters, maps, lists (queues, stacks), sets, etc.
Stars: ✭ 157 (+93.83%)
Mutual labels:  dictionary, map
Libdict
C library of key-value data structures.
Stars: ✭ 234 (+188.89%)
Mutual labels:  dictionary, map
Stencil Store
Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.
Stars: ✭ 107 (+32.1%)
Mutual labels:  dictionary, map
Imtools
Fast and memory-efficient immutable collections and helper data structures
Stars: ✭ 85 (+4.94%)
Mutual labels:  dictionary, map
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (+54.32%)
Mutual labels:  array, map
Hashmap
HashMap JavaScript class for Node.js and the browser. The keys can be anything and won't be stringified
Stars: ✭ 363 (+348.15%)
Mutual labels:  array, map
Pgo
Go library for PHP community with convenient functions
Stars: ✭ 51 (-37.04%)
Mutual labels:  array, map
Mjextension
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.
Stars: ✭ 8,458 (+10341.98%)
Mutual labels:  dictionary, array

dyno

Build Status GoDoc Go Report Card codecov

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.

Supported Operations

Example

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:

src := `{"login":{"password":"secret","user":"bob"},"name":"cmpA"}`
var v interface{}
if err := json.Unmarshal([]byte(src), &v); err != nil {
	panic(err)
}
// Edit (mask out) password:
if err = dyno.Set(v, "xxx", "login", "password"); err != nil {
	fmt.Printf("Failed to set password: %v\n", err)
}
edited, err := json.Marshal(v)
fmt.Printf("Edited JSON: %s, error: %v\n", edited, err)

Output will be:

Edited JSON: {"login":{"password":"xxx","user":"bob"},"name":"cmpA"}, error: <nil>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].