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

Issue #1242 : Support for comma delimited lists in String[], int[] and short[] #1364

Closed
wants to merge 1 commit into from

Conversation

LokeshN
Copy link
Contributor

@LokeshN LokeshN commented Sep 6, 2016

Implementation to support for comma delimited lists in String[], int[] and short[].
@cowtowncoder, let me know if it needs some improvement.

Thanks,
LokeshN

@@ -26,6 +26,8 @@
* @since 2.7
*/
protected final Boolean _unwrapSingle;

protected JsonFormat.Value _format;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be made final, for immutability. See below for more on this.

@cowtowncoder
Copy link
Member

@LokeshN first of all, thank you for this PR. Supporting a way to encode/decode simple (scalar-valued) arrays and Lists as comma-separated Strings is something that is useful.
I also think use of @JsonFormat makes sense.

There are some technical details that would need changing (esp. immutability of serializers/deserializers; can not have mutable _pattern field).
But beyond this, I think one big question is configurability: how should separator be defined? And is there a way to use the same format for reading and writing -- for reading, a JDK Pattern would work, either describing separator or split rule (former more efficient). But would it work for serialization?
I guess we could alternatively just interpret pattern as static String (it's easy to create bogus Pattern to still be able to split on it), as that is likely to cover most or all use cases.

Beyond this, I think feature should work for both arrays and Collections, I think, since List<String> is usually quite interchangeable with String[].

Perhaps it would be good to briefly discuss this on jackson-dev list?

@LokeshN
Copy link
Contributor Author

LokeshN commented Sep 12, 2016

@cowtowncoder Thanks for the review. I got the purpose of createContextual() method where I can't store the pattern to use it later. I will change that implementation to create new serializers and deserializers for comma separated lists. Also for representing the pattern in jsonformat, I have posted it in jackson-dev, will check the responses for the post and then we will decide which way to go forward.

Thanks,
Lokesh

@cowtowncoder
Copy link
Member

While I think the idea itself is worth considering, I don't think I want to proceed with this implementation; closing.

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.

None yet

2 participants