Guest User

Untitled

a guest
Dec 15th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. {"amount" : null}
  2.  
  3. class BigDecimalDeserializer : JsonDeserializer<BigDecimal> {
  4. override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): BigDecimal {
  5.  
  6. if (json!!.isJsonNull) {
  7. return BigDecimal.ZERO
  8. }
  9.  
  10. json?.let {
  11.  
  12. try {
  13. json.asBigDecimal
  14. } catch (t: NumberFormatException) {
  15. return BigDecimal.ZERO
  16. }
  17.  
  18. }
  19.  
  20. return json?.asBigDecimal!!
  21. }
Add Comment
Please, Sign In to add comment