In Spring java application, I am receiving REST json request with following input where 'mode' field is defined as byte in the java class.
{
"application": "sadsd",
"date": "20161109",
"mode": "A",
"catalogId": 0,
}
pojo -
public class Test {
String application;
String date;
byte mode;
int catalogId;
...
}
getting Following error -
"exception": org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Could not read document: Can not deserialize value of type byte from String \"A\":
not a valid Byte value\n at
[Source: java.io.PushbackInputStream@6386b197; line: xx, column: xx]
(through reference chain: com.abc.myInput[\"mode\"]);
`enter code here`nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException:
Can not deserialize value of type byte from String \"A\":
not a valid Byte value\n at [Source: java.io.PushbackInputStream@6386b197; line: xx, column: xx]
(through reference chain: com.abc.myInput[\"mode\"])",`
Do i have to write serializer and deserializer here?
Are there any annotations that i can use on byte field or get/set methods of that field without writing any additional code?