jackson-dataformat-csv icon indicating copy to clipboard operation
jackson-dataformat-csv copied to clipboard

Unable to skip column using JSONPropertyOrder

Open shankyty opened this issue 9 years ago • 4 comments

Unable to skip column in csv using JSONPropertyOrder My use case is to load few speicfic columns, also needs to skip most of the columns

shankyty avatar Nov 05 '16 14:11 shankyty

I don't understand: skip? How would @JSONPropertyOrder help? CSV is positional so you must specify all columns the precede ones you need; there's no way around that.

You can, if that helps, just bind rows as String[] (or List<String>), and then extract positions you care about.

cowtowncoder avatar Nov 09 '16 18:11 cowtowncoder

But I can specific column number using @JsonProperty("6") something like this for csv then I do not have create schema separately before calling mapper.read

On Thu, Nov 10, 2016, 12:21 AM Tatu Saloranta [email protected] wrote:

I don't understand: skip? How would @JSONPropertyOrder help? CSV is positional so you must specify all columns the precede ones you need; there's no way around that.

You can, if that helps, just bind rows as String[](or List<String), and then extract positions you care about.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FasterXML/jackson-dataformat-csv/issues/136#issuecomment-259493331, or mute the thread https://github.com/notifications/unsubscribe-auth/AE5wUryTcjcJ9durtou0zALHrPwLTrHnks5q8hYVgaJpZM4KqRRC .

shankyty avatar Nov 10 '16 02:11 shankyty

@shankyty No. Properties are specified by name with that notation, and having JSON property name like "6" is completely legal (even if unlikely).

However, there is index:

@JsonProperty(index=6)

which could conceivably allow doing this. So... perhaps something like this could be done, theoretically speaking, if anyone wanted to work on this.

I could modify the title, or create a new issue, for this idea.

cowtowncoder avatar Nov 10 '16 03:11 cowtowncoder

Reply I can work on this since I need it and I think it would cleaner approach for me too.

On Thu, Nov 10, 2016, 9:19 AM Tatu Saloranta [email protected] wrote:

@shankyty https://github.com/shankyty No. Properties are specified by name with that notation, and having JSON property name like "6" is completely legal (even if unlikely).

However, there is index:

@JsonProperty(index=6)

which could conceivably allow doing this. So... perhaps something like this could be done, theoretically speaking, if anyone wanted to work on this.

I could modify the title, or create a new issue, for this idea.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/FasterXML/jackson-dataformat-csv/issues/136#issuecomment-259595319, or mute the thread https://github.com/notifications/unsubscribe-auth/AE5wUvY6o8aPePXqbRVb1Asu3fiuBtiuks5q8pQvgaJpZM4KqRRC .

shankyty avatar Nov 10 '16 04:11 shankyty