Skip to content

BUGFIX: allow json tag overrides with set naming strategy #275

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

Closed
wants to merge 2 commits into from

Conversation

shdunning
Copy link

This allows users to use a set naming strategy, like so...

extra.SetNamingStrategy(extra.LowerCaseWithUnderscores)

...but also alias a field via the json tag to rename it:

type Response struct {
	Var1		string `json:"var"`
	FooBar	string
}

The above will result in the following JSON structure: {"var":"some string value", "foo_bar":"some other string value"}.

Prior to this change, one could not alias a struct field via the json tag to rename and have a set naming strategy.

@codecov
Copy link

codecov bot commented May 25, 2018

Codecov Report

Merging #275 into master will increase coverage by 0.17%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #275      +/-   ##
==========================================
+ Coverage   81.35%   81.53%   +0.17%     
==========================================
  Files          41       41              
  Lines        4978     4982       +4     
==========================================
+ Hits         4050     4062      +12     
+ Misses        811      803       -8     
  Partials      117      117
Impacted Files Coverage Δ
reflect_extension.go 88.08% <84.61%> (-0.23%) ⬇️
reflect_struct_decoder.go 46.72% <0%> (+1.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ddf6d7...beea542. Read the comment docs.

@shdunning
Copy link
Author

Another one for you @taowen when you get some time plz

@taowen
Copy link
Contributor

taowen commented Jul 1, 2018

adding extra fields to binding is not needed.

@taowen taowen closed this Jul 1, 2018
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.

2 participants