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
Nested Classes -
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 anAccountinstance from the JSON request.getBigDecimal(String attribute) Helper method to retrieve aBigDecimalvalue from the JSON request.getComputedDate(String attribute) Helper method to retrieve aComputedDatevalue from the JSON request.getComputedDouble(String attribute) Helper method to retrieve aComputedDoublevalue from the JSON request.getComputedInteger(String attribute) Helper method to retrieve aComputedIntegervalue from the JSON request.getComputedLong(String attribute) Helper method to retrieve aComputedLongvalue from the JSON request.getComputedMinute(String attribute) Helper method to retrieve aComputedMinutevalue from the JSON request.Class<? extends StoredObject> getDataClass(String attribute) Helper method to retrieve aStoredObjectclass 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 aDatePeriodvalue from the JSON request assuming that "dateFrom" and "dateTo" are the names of the attributes.Helper method to retrieve aDoublevalue from the JSON request.Helper method to retrieve aIdfrom the JSON request.getInteger(String attribute) Helper method to retrieve aIntegervalue from the JSON request.Helper method to retrieve aLongvalue 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 aStringListfrom 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
-
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 aMapor 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) AJsonNodeinstance - directly set internally, (2) AnotherJSONinstance - directly set internally, (3) AnInputStreaminstance - expects a string value from the stream, (4) An instance of aReader- expects a string value from it, (5) AURLinstance - content from theURLis read and processed.- Parameters:
object- JSON to construct from this Object.
-
-
Method Details
-
get
-
get
-
get
Description copied from class:JSONRetrieve the value for the given key and get the value from the given position from that value, assuming that value is an array type.Nullwill 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 aComputedDatevalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
ComputedDatevalue if found, otherwise null.
-
getComputedMinute
Helper method to retrieve aComputedMinutevalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
ComputedMinutevalue if found, otherwise null.
-
getComputedDouble
Helper method to retrieve aComputedDoublevalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
ComputedDoublevalue if found, otherwise null.
-
getComputedInteger
Helper method to retrieve aComputedIntegervalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
ComputedIntegervalue if found, otherwise null.
-
getComputedLong
Helper method to retrieve aComputedLongvalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
ComputedLongvalue if found, otherwise null.
-
getInteger
-
getLong
-
getDouble
-
getBigDecimal
Helper method to retrieve aBigDecimalvalue from the JSON request.- Parameters:
attribute- Attribute name.- Returns:
BigDecimalvalue if found, otherwise null.
-
getStringList
Helper method to retrieve aStringListfrom the JSON request.- Parameters:
attribute- Attribute name.- Returns:
StringListif found, otherwise null.
-
getDatePeriod
Helper method to retrieve aDatePeriodvalue from the JSON request assuming that "dateFrom" and "dateTo" are the names of the attributes.- Returns:
BigDecimalvalue if found, otherwise null.
-
getDataClass
Helper method to retrieve aStoredObjectclass value from the JSON request.- Returns:
StoredObjectclass 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
-