适配TinyInt
This commit is contained in:
@@ -11,21 +11,18 @@ import java.io.IOException;
|
||||
* @Description:
|
||||
* @date 2025-03-07 13:32
|
||||
*/
|
||||
public class TinyIntTypeAdapter extends TypeAdapter<Number> {
|
||||
public class TinyIntTypeAdapter extends TypeAdapter<Byte> {
|
||||
@Override
|
||||
public void write(JsonWriter out, Number value) throws IOException {
|
||||
public void write(JsonWriter out, Byte value) throws IOException {
|
||||
if (value == null) {
|
||||
out.nullValue();
|
||||
} else {
|
||||
out.value(value.intValue()); // 强制转换为整数
|
||||
out.value(value.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number read(JsonReader in) throws IOException {
|
||||
if (in.peek() == null) {
|
||||
return null;
|
||||
}
|
||||
return in.nextInt(); // 读取为整数
|
||||
public Byte read(JsonReader in) throws IOException {
|
||||
throw new UnsupportedOperationException("Unreadable");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user