Here you can find the source of toBigDecimal(JsonValue val)
public static BigDecimal toBigDecimal(JsonValue val)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.util.function.Function; import javax.json.JsonNumber; import javax.json.JsonString; import javax.json.JsonValue; public class Main { public static BigDecimal toBigDecimal(JsonValue val) { if (val instanceof JsonNumber) { return ((JsonNumber) val).bigDecimalValue(); }/*from w ww. ja v a 2 s .c om*/ return new BigDecimal(toString(val)); } public static String toString(JsonValue val) { return toObject(val, v -> { if (v instanceof JsonString) { return ((JsonString) v).getString(); } return v.toString(); }); } public static <T extends JsonValue, R> R toObject(T val, Function<T, R> function) { if (val == null || val == JsonValue.NULL) { return null; } return function.apply(val); } }