mitchellh / mapstructure

Go library for decoding generic map values into native Go structures and vice versa.
https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc
MIT License
7.93k stars 677 forks source link

Renaming fields via json: directive #268

Closed ITler closed 2 years ago

ITler commented 2 years ago

Hello. First thank you for providing this library. It is very helpful.

I would like to propose the following: To reduce repitition in code when it comes to mapping field names maybe changing from

`mapstructure: "alternativeFieldname"` 

to

`json: "alternativeFieldname"`

would be useful, as I think the json: directive would be used and defined on the struct anyways. Kind of relates to: #256

What do you think?

Necoro commented 2 years ago

You can set the tag name to use in your DecoderConfig if you want something like this. For example, I reuse yaml-tags. Isn't this sufficient?

ITler commented 2 years ago

Argh, I am blind. Of cause this is sufficient. Thanks for replying.