yasson
yasson copied to clipboard
ZoneId serialization not normalized
Describe the bug
According to the JSON-B specification a java.time.ZoneId instance needs to be serialized as follows (emphasis mine):
Implementations MUST support the deserialization of any time zone ID format specified in java.time.ZoneId into a field or property of type java.time.ZoneId. The serialization format of java.time.ZoneId is the normalized zone ID as specified in java.time.ZoneId.
The normalized part makes a difference when you have a ZoneId.of("UTC"), for example. The zone ID is "UTC", but the normalized zone ID is "Z", as shown by this jshell session:
jshell> import java.time.*;
jshell> ZoneId.of("UTC").getId()
$2 ==> "UTC"
jshell> ZoneId.of("UTC").normalized().getId()
$3 ==> "Z"
To Reproduce
> System.out.println(jsonb.toJson(ZoneId.of("UTC")));
==> "UTC"
Expected behavior
Expected to serialize ZoneId.of("UTC") as "Z" and not as "UTC".
System information:
- OS: macOS 10.14.6
- Java Version: 8 & 11
- Yasson Version: 1.0.6
Fixed by #418
FYI I had to revert PR #418 from @Degubi because it was causing a TCK test to fail. We didn't notice it failed a TCK test originally because CI was accidentally running Yasson unit tests a second time instead of running the TCK tests.
I think this is a change that we need to make, but we have to go through the proper process first of a TCK challenge and get this sorted out at the spec level before we can change our behavior.