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

unbox value class in Map key when serializing #470

Merged
merged 7 commits into from
Sep 28, 2021

Conversation

k163377
Copy link
Contributor

@k163377 k163377 commented Jun 24, 2021

This PR is a continuation of #468, and a fix for #469.
This change will also cause unboxing when value class is set as key.
The tests now reflect this as well.

Repletion

About the behavior when WrapperClass is set to key

#468 described a pattern that would unbox the value class field when the WrapperClass was set to key.
On the other hand, this appeared to be a behavior that improperly overrides the toString method of the WrapperClass, so it has been removed.

Fixed NullValueSerializer being ignored when unbox result is null

In the previous PR, there was a problem that null was written ignoring the NullValueSerializer when the result of unbox was null.
Test cases have been added as well.

Question

The JSON string output by writerWithDefaultPrettyPrinter respects the newline code of the platform, but the Kotlin raw string always seems to use \n.
This is why the Github464 test is failing on my Windows environment.

How should I fix this problem?
I believe that replacing \r\n with \n for both output results would superficially solve the problem, but I'm wondering if there is a better fix.

@dinomite
Copy link
Member

I think the line separator is because the raw strings are so raw as to abide by the encoding of the source file, and therefore use the \n therein, since that test file is in Unix format. I'm not sure of an elegant solution to this, aside from building the strings using .lineSeparator(), but that's ugly. They'll pass in CI, which is the important thing.

@dinomite dinomite merged commit 80262de into FasterXML:2.13 Sep 28, 2021
@k163377 k163377 deleted the github_464_pr3 branch September 29, 2021 14:32
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