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

Any appearance of "get" in property name is replaced with empty string #61

Open
pareshd opened this issue Nov 26, 2018 · 1 comment
Open

Comments

@pareshd
Copy link

pareshd commented Nov 26, 2018

Thank you for creating and maintaining this extremely useful library.
I have run into the following issue recently after upgrading to 1.0.1.

Whenever a property name itself contains the string literal "get" as part of its name, it gets replaced with an empty string in the final output. For example: "budget" becomes "bud" or "targets" becomes "tars".

The culprit seems to be in the following method in JsonViewSerializer:

private String getFieldNameFromGetter(Method method) {
      String name = method.getName().replace("get", "");
      return name.substring(0, 1).toLowerCase() + name.substring(1);
    }

I think replaceFirst instead of replace would solve this issue.

Thanks!

pareshd pushed a commit to pareshd/json-view that referenced this issue Nov 26, 2018
monitorjbl added a commit that referenced this issue Nov 28, 2018
Fix for issue (#61): Any appearance of "get" in property name is replaced with empty string
@ZefieriaX12
Copy link
Contributor

Hi, love your work,

I want to add on to this issue. I think you might also want to check if the method name is simply "get".

I encountered this issue in Spring Boot 2.1 with the org.springframework.data.domain.Page interface which extends org.springframework.data.domain.Slice->org.springframework.data.util.Streamable.
Streamable which contains the following method:

default Stream<T> get() {
	return stream();
}

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

No branches or pull requests

2 participants