-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
[jackson-dataformat-csv:2.8.11/2.12.2]CsvMapper unrecognised the @JsonProperty #268
Comments
First things, first: PLEASE DO NOT USE
on tests. This is VERY common way to hide simple problems that you could fix if you saw them. Second: if input contains header line (which I think is the case here), your schema must indicate this:
You probably do not need create schema from POJO class either, as long as names from header line match expected property names (either from getter name, or via annotation). With these changes you may be able to get better results and see if there are other problems. |
@cowtowncoder Second: schema = schema.withUseHeader(true); I had a try a few days ago with the same result. POJO property names does not match the CSV header. You can open the two files: appsflyer-raw-data.csv |
To me header line names do seem to match annotated names?
At this point I would need either:
|
No any exception on fails. |
A test case that shows the problem with assertions would help: the original picture simply showed a POJO with values, some of which were |
Hello @cowtowncoder , I recently came across that issue because I faced the same problem within one of my projects. https://github.com/sbszcz/jackson-csv-java-example Mapping the content of the columns does not work. I have no idea why. The content seems to be mapped to arbitrary pojo properties. Could you please have a look at this? Thank you, |
Looking at the example @sbszcz (thank you!) -- my first instinct is that I don't understand why there is no fail for non-annotated case since there is no match from header names to actual names. |
@sbszcz A few issues with the code, solving of which will make things work. First: you should not usually (need to) combine 2 types of
which ensures that the information is combined: otherwise explicitly specified schema (from POJO, and ordering it defines) is used. So, instead of starting with The problem without using annotations is that there is no mapping between names from CSV file header (in German) and property names in
Or, even specify the expected ordering for POJO Fields with |
@zhaoxi2000 I think you have the same problem: your POJO definition does not specify ordering of properties with Instead leave out the whole |
At this point I don't see actual bug to fix, but I want to help ensure that usage can be changed to work for the use case, so keeping issue open. |
the result is
AppsFlyerRawDataBean.java.txt
appsflyer-raw-data.csv
The text was updated successfully, but these errors were encountered: