Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Decode underscore value #302

Open
mussa572 opened this issue Aug 21, 2022 · 3 comments
Open

Decode underscore value #302

mussa572 opened this issue Aug 21, 2022 · 3 comments

Comments

@mussa572
Copy link

Hi I have Jason field k8s_version which contain underscore. However I have noticed that I am not able to decode values with _. Just wondering if its a bug or required me to add anything

@lkendrickd
Copy link

lkendrickd commented Sep 14, 2022

You can decode those if you tag them like this.

	// UserAccount - this type is purposely showing the emailskip field in the data is not present
	type User struct {
		Name     string
		IsActive bool `mapstructure:"is_active"`
	}

and the data with the _

	uinput := map[string]interface{}{
		"name":      "UserB",
		"is_active": true,
	}

I found that looking through the notes in the actual source file and in the comments it speaks on how to do it.

Printed Output

main.User{Name:"UserB", IsActive:true}

@SkyWingZhang
Copy link

nonono this is bug
image

@SkyWingZhang
Copy link

SkyWingZhang commented Feb 21, 2023

so ga very good
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants