Package com.storedobject.core
Class JSON
java.lang.Object
com.storedobject.common.JSON
com.storedobject.core.JSON
Extended JSON class with more extract methods for the core-specific attribute types.
- Author:
- Syam
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int n) Get the value at position 'n' assuming that this is an array.Get the value for the given key.Retrieve the value for the given key and get the value from the given position from that value, assuming that value is an array type.getAccount
(String attribute) Helper method to retrieve anAccount
instance from the JSON request.getBigDecimal
(String attribute) Helper method to retrieve aBigDecimal
value from the JSON request.getComputedDate
(String attribute) Helper method to retrieve aComputedDate
value from the JSON request.getComputedDouble
(String attribute) Helper method to retrieve aComputedDouble
value from the JSON request.getComputedInteger
(String attribute) Helper method to retrieve aComputedInteger
value from the JSON request.getComputedLong
(String attribute) Helper method to retrieve aComputedLong
value from the JSON request.getComputedMinute
(String attribute) Helper method to retrieve aComputedMinute
value from the JSON request.Class
<? extends StoredObject> getDataClass
(String attribute) Helper method to retrieve aStoredObject
class value from the JSON request.getDate()
Helper method to retrieve a date value from the JSON request assuming that the attribute name is "date".Helper method to retrieve a date value from the JSON request.Helper method to retrieve aDatePeriod
value from the JSON request assuming that "dateFrom" and "dateTo" are the names of the attributes.Helper method to retrieve aDouble
value from the JSON request.Helper method to retrieve aId
from the JSON request.getInteger
(String attribute) Helper method to retrieve aInteger
value from the JSON request.Helper method to retrieve aLong
value from the JSON request.Helper method to retrieve a monetary value from the JSON request.getQuantity
(String attribute) Helper method to retrieve a quantity value from the JSON request.getStringList
(String attribute) Helper method to retrieve aStringList
from the JSON request.Helper method to retrieve a time value from the JSON request.getTimestamp
(String attribute) Helper method to retrieve a timestamp value from the JSON request.Methods inherited from class com.storedobject.common.JSON
containsKey, create, create, encode, fromJSS, getArraySize, getBoolean, getBoolean, getBoolean, getDecimal, getDecimal, getDecimal, getNumber, getNumber, getNumber, getString, getString, getString, getType, isNull, keys, parseJSS, prettyWrite, set, toMap, toPrettyString, toPrettyString, toString, toString, write
-
Field Details
-
DATE_FORMAT
-
DATE_TIME_FORMAT
-
TIME_FORMAT
-
-
Constructor Details
-
JSON
public JSON()Construct an empty JSON. -
JSON
Construct a JSON instance from an Object that could hopefully parse into a JSON compatible String. Typically, it could be aMap
or some sort of array or collection. It could also be a standalone object that can be converted to a valid JSON string. Otherwise, the following types are handled as special cases: (1) AJsonNode
instance - directly set internally, (2) AnotherJSON
instance - directly set internally, (3) AnInputStream
instance - expects a string value from the stream, (4) An instance of aReader
- expects a string value from it, (5) AURL
instance - content from theURL
is read and processed.- Parameters:
object
- JSON to construct from this Object.
-
-
Method Details
-
get
-
get
-
get
Description copied from class:JSON
Retrieve the value for the given key and get the value from the given position from that value, assuming that value is an array type.Null
will be returned if this isnull
, key isnull
, no value exists for the given key, the value type is not an array or nothing found at the given position. -
getDate
-
getDate
Helper method to retrieve a date value from the JSON request assuming that the attribute name is "date".- Returns:
- Date if found, otherwise null.
-
getTimestamp
-
getTime
-
getId
-
getQuantity
-
getMoney
-
getComputedDate
Helper method to retrieve aComputedDate
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
ComputedDate
value if found, otherwise null.
-
getComputedMinute
Helper method to retrieve aComputedMinute
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
ComputedMinute
value if found, otherwise null.
-
getComputedDouble
Helper method to retrieve aComputedDouble
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
ComputedDouble
value if found, otherwise null.
-
getComputedInteger
Helper method to retrieve aComputedInteger
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
ComputedInteger
value if found, otherwise null.
-
getComputedLong
Helper method to retrieve aComputedLong
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
ComputedLong
value if found, otherwise null.
-
getInteger
-
getLong
-
getDouble
-
getBigDecimal
Helper method to retrieve aBigDecimal
value from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
BigDecimal
value if found, otherwise null.
-
getStringList
Helper method to retrieve aStringList
from the JSON request.- Parameters:
attribute
- Attribute name.- Returns:
StringList
if found, otherwise null.
-
getDatePeriod
Helper method to retrieve aDatePeriod
value from the JSON request assuming that "dateFrom" and "dateTo" are the names of the attributes.- Returns:
BigDecimal
value if found, otherwise null.
-
getDataClass
Helper method to retrieve aStoredObject
class value from the JSON request.- Returns:
StoredObject
class value if found, otherwise an exception is raised.- Throws:
Exception
- is thrown if class name can't be extracted or the name is invalid.
-
getAccount
-