- java.lang.Object
-
- com.github.wnameless.json.base.JsonValueUtils
-
public final class JsonValueUtils extends Object
JsonValueUtilsprovides convenient methods to generate Java objects from any JSON wrapper in this library.- Author:
- Wei-Ming Wu
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NumbertoJavaNumber(BigDecimal bd)Creates aNumberby givenBigDecimalfromInteger,Long,BigInteger,DoubleandBigDecimalbased on the size and scale of numeric.static List<Object>toList(JsonArrayBase<?> jsonArray)Creates aListby givenJsonArrayBase.static Map<String,Object>toMap(JsonObjectBase<?> jsonObject)Creates aMapby givenJsonObjectBase.static ObjecttoObject(JsonValueBase<?> jsonValue)Creates a JavaObjectfrom givenJsonValueBase.
-
-
-
Method Detail
-
toObject
public static Object toObject(JsonValueBase<?> jsonValue)
Creates a JavaObjectfrom givenJsonValueBase.- Parameters:
jsonValue- aJsonValueBase- Returns:
- an
Objectcorresponds to JSON value - Throws:
IllegalStateException- if givenJsonValueBaseis not represented as any JSON value
-
toJavaNumber
public static Number toJavaNumber(BigDecimal bd)
Creates aNumberby givenBigDecimalfromInteger,Long,BigInteger,DoubleandBigDecimalbased on the size and scale of numeric.- Parameters:
bd- aBigDecimal- Returns:
- a
Number
-
toList
public static List<Object> toList(JsonArrayBase<?> jsonArray)
Creates aListby givenJsonArrayBase.- Parameters:
jsonArray- aJsonArrayBase- Returns:
- a
List
-
toMap
public static Map<String,Object> toMap(JsonObjectBase<?> jsonObject)
Creates aMapby givenJsonObjectBase.- Parameters:
jsonObject- aJsonObjectBase- Returns:
- a
Map
-
-