Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly handle embedded (anonymous) fields #4

Merged
merged 1 commit into from
Oct 16, 2017
Merged

properly handle embedded (anonymous) fields #4

merged 1 commit into from
Oct 16, 2017

Conversation

faryon93
Copy link
Contributor

The json package handles marshaling of an anonymous field as following:

type Sub struct {
	Foo string `json:"foo"`
}

type Top struct {
	*Sub
	Bar string `json:"bar"`
}

func main() {
	v := Top{
		&Sub{"Hello"},
		"World!",
	}
	
	buf, _ := json.Marshal(v)
	fmt.Println(string(buf))
}
{"foo":"Hello","bar":"World!"}

With sheriff the anonymous field would be ignored. To make the output of sheriff as close as possible to the embedded json package, this pull request contains the changes to reflect the desired behaviour.

Kind regards,
Maxi

@coveralls
Copy link

coveralls commented Oct 14, 2017

Coverage Status

Coverage increased (+1.4%) to 81.707% when pulling d0d9181 on faryon93:master into 2245bc6 on liip:master.

@mweibel mweibel merged commit 73de227 into liip:master Oct 16, 2017
@mweibel
Copy link
Collaborator

mweibel commented Oct 16, 2017

Awesome, thanks!

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

Successfully merging this pull request may close these issues.

3 participants