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?