The JsonParser.isIntegralNumber() spec states that:
@throws IllegalStateException - when the parser state is not VALUE_NUMBER
Unfortunately, when running calling that method on a container that uses Yasson, it throws the JsonbException instead;
Here's the stacktrace:
jakarta.json.bind.JsonbException: Value type STRING at key id is not a JsonNumber.
at org.eclipse.yasson.internal.jsonstructure.JsonObjectIterator.createIncompatibleValueError(JsonObjectIterator.java:130)
at org.eclipse.yasson.internal.jsonstructure.JsonStructureToParserAdapter.getJsonNumberValue(JsonStructureToParserAdapter.java:122)
at org.eclipse.yasson.internal.jsonstructure.JsonStructureToParserAdapter.isIntegralNumber(JsonStructureToParserAdapter.java:88)
at org.eclipse.yasson.internal.deserializer.YassonParser.isIntegralNumber(YassonParser.java:96)
This breaks the code that we've implemented when implementing and running the custom JsonbDeserializer.deserialize() method:
RequestId id = null;
try {
if (parser.isIntegralNumber()) {
id = RequestId.of(parser.getLong());
}
} catch (IllegalStateException e) {
id = RequestId.of(parser.getString());
}
System information:
- OS: Windows 10
- Java Version: 26
- Yasson Version: 3.0.3
- Jakarta EE container: Eclipse GlassFish Embedded 9.0.0-M1
Note: This is not an issue on Parsson.
The
JsonParser.isIntegralNumber()spec states that:Unfortunately, when running calling that method on a container that uses Yasson, it throws the
JsonbExceptioninstead;Here's the stacktrace:
This breaks the code that we've implemented when implementing and running the custom
JsonbDeserializer.deserialize()method:System information:
Note: This is not an issue on Parsson.