I'm receiving invalid value for `Byte` field during deserialization.
Json:
{"byteField" : 128 }
Java:
class Dto {
private Byte byteField;
... getter/setter
}
After deserialization I'm receiving `Dto.byteField` = -128
I found next code in Jackon-core library v.2.11.0 in
`com.fasterxml.jackson.core.JsonParser#getByteValue`
public byte getByteValue() throws IOException {
int value = getIntValue();
// So far so good: but does it fit?
// [JACKSON-804]: Let's actually allow range of [-128, 255], as
those are uniquely mapped
// (instead of just signed range of [-128, 127])
if (value < MIN_BYTE_I || value > MAX_BYTE_I) {
throw new InputCoercionException(this,
String.format("Numeric value (%s) out of range of Java
byte", getText()),
JsonToken.VALUE_NUMBER_INT, Byte.TYPE);
}
return (byte) value;
}
but not able to find issue JACKSON-804 as well as any discussion about byte
range.
Question:
- Why Jackson allows to byte be more than 127?
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/3f4b00d6-8c96-488e-8958-9fd1b18b57a7%40googlegroups.com.