Here you can find the source of getBigDecimal(JsonObject object, String memberName)
Parameter | Description |
---|---|
object | json object |
memberName | member's name |
public static BigDecimal getBigDecimal(JsonObject object, String memberName)
//package com.java2s; //License from project: Open Source License import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import java.math.BigDecimal; public class Main { /**//from w w w.java2 s .c o m * Gets nullable BigDecimal from a JSON object. * * @param object json object * @param memberName member's name * @return {@link java.math.BigDecimal} value */ public static BigDecimal getBigDecimal(JsonObject object, String memberName) { JsonPrimitive primitive = getPrimitiveChecked(object, memberName); return primitive == null ? null : primitive.getAsBigDecimal(); } private static JsonPrimitive getPrimitiveChecked(JsonObject object, String memberName) { checkParameters(object, memberName); return object.getAsJsonPrimitive(memberName); } private static void checkParameters(JsonObject object, String memberName) { checkObject(object); checkMemberName(memberName); } private static void checkObject(JsonObject object) { if (object == null) { throw new NullPointerException("JSON object is null."); } } private static void checkMemberName(String memberName) { if (memberName == null) { throw new NullPointerException("Member name is null."); } if (memberName.length() == 0) { throw new IllegalArgumentException("Member is an empty string."); } } }