zhangyeguang
3 months ago
5 changed files with 37 additions and 7 deletions
@ -0,0 +1,21 @@ |
|||
package com.jiagutech.ams.utils; |
|||
|
|||
import com.fasterxml.jackson.core.JsonParser; |
|||
import com.fasterxml.jackson.databind.DeserializationContext; |
|||
import com.fasterxml.jackson.databind.JsonDeserializer; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
public class StringToIntegerDeserializer extends JsonDeserializer<Integer> { |
|||
|
|||
@Override |
|||
public Integer deserialize(JsonParser jsonParser, DeserializationContext context) |
|||
throws IOException { |
|||
String value = jsonParser.getText(); |
|||
try { |
|||
return Integer.parseInt(value); |
|||
} catch (NumberFormatException e) { |
|||
throw new IOException("Unable to parse value as Long: " + value, e); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue