mapstructure
mapstructure copied to clipboard
Go library for decoding generic map values into native Go structures and vice versa.
In the [_Buy Why?!_](https://github.com/mitchellh/mapstructure#but-why) section in the README is says: > For example, consider this JSON: > > > ```json > { > "type": "person", > "name": "Mitchell" > }...
This allows to map structures into typed maps. The typed map type must match the structure type. Test have been added. Fixes #311
When the target map to decode the result to is strongly typed, the decoding process fails, even if the map type matches the source structure. ``` func TestDecode_structToTypedMap(t *testing.T) {...
I have a situation where I don't know the target struct and hence decode into a map. This will create duplicate keys if input has multiple types of key case....
 Please this example is unrelated and could lead to more confusion
Hello, I've come across and issue where when trying to convert a [Gorm](https://gorm.io) Model, which has a field of `gorm.io/datatypes/JSON`, and a value similar to `["a", "b", "c"]`. It looks...
Hi, I came across an interesting side-effect of the changes introduced in v1.3.2 in the `decodeBasic` function (93663c4d5b1f33be88f4083d3c7451ed0c1439fb) in the 99designs/gqlgen codebase. The following reproducer runs fine prior the version...
I use the DecodeHook to translate the *values* of certain fields. This works great when "decoding" from map -> struct, but doesn't work the other way around. When I "encode"...
Hooks are difficult to get 100% correct. When there is an error in the code using reflection, we are likely to trigger a panic. While a panic is helpful to...
I've just had the requirement, to provide specific unmarshaling of some structures without modifying the unmarshaler configuration. I already have `WeaklyTypedInput` and `DecodeHook`/`ComposeDecodeHookFunc`. I'd like to propose implementing an `UnmarshallerHookFunc`...