Class JsonDeserializer
java.lang.Object
cz.metacentrum.perun.rpc.deserializer.Deserializer
cz.metacentrum.perun.rpc.deserializer.JsonDeserializer
Deserializer for JSON / JSONP data format.
Reads parameters from body (InputStream) of request which is typically POST. Doesn't read any parameters form URL!
While deserializing objects from JSON some of their properties may be ignored. They are not read from input and also not required to be present in input in order to match JSON object to the right Java object. They are set as NULL in Java object (if present as variable) or ignored at all.
- Author:
- Jan Klos invalid input: '<'ddd@mail.muni.cz>, Pavel Zlamal invalid input: '<'256627@mail.muni.cz>
-
Constructor Summary
ConstructorsConstructorDescriptionJsonDeserializer(jakarta.servlet.http.HttpServletRequest request) Create deserializer for JSON/JSONP data format. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif value with the specified name is supplied.jakarta.servlet.http.HttpServletRequestReturn HttpServletRequest related to concrete call this deserializer is used to process.<T> TReads value from root Json node.<T> TReads value with the specified name asvalueType.readAll()Returns string representation of the variables stored in the deserializer.int[]readArrayOfInts(String name) readBoolean(String name) Reads value with the specified name asBoolean.intReads value with the specified name asint.<T> List<T> Reads array from root Json node.<T> List<T> Reads array with the specified name asList<valueType>.readListPerunBeans(String name) Reads array with the specified name asList<PerunBean>.readPerunBean(String name) Reads value with the specified name asPerunBean.readString(String name) Reads value with the specified name asString.Reads value with the specified name asUUID.Methods inherited from class cz.metacentrum.perun.rpc.deserializer.Deserializer
readLocalDate, stateChangingCheck
-
Constructor Details
-
JsonDeserializer
Create deserializer for JSON/JSONP data format.- Parameters:
request- HttpServletRequest this deserializer is about to process- Throws:
IOException- if an IO error occursRpcException- if content ofinis wrongly formatted
-
JsonDeserializer
- Throws:
IOException
-
-
Method Details
-
contains
Description copied from class:DeserializerReturnstrueif value with the specified name is supplied.- Specified by:
containsin classDeserializer- Parameters:
name- name of the value to check- Returns:
trueif value with the specified name is supplied,falseotherwise
-
getServletRequest
public jakarta.servlet.http.HttpServletRequest getServletRequest()Description copied from class:DeserializerReturn HttpServletRequest related to concrete call this deserializer is used to process.Note that this "request" is not necessarily used as source to read parameters by other methods of deserializer. It IS typically for GET requests, but NOT for POST with JSON/JSONP data format.
- Overrides:
getServletRequestin classDeserializer- Returns:
- HttpServletRequest related to concrete call
-
read
Description copied from class:DeserializerReads value from root Json node.- Overrides:
readin classDeserializer- Parameters:
valueType- type of the value to read- Returns:
- the value as
valueType
-
read
Description copied from class:DeserializerReads value with the specified name asvalueType.- Overrides:
readin classDeserializer- Parameters:
name- name of the value to readvalueType- type of the value to read- Returns:
- the value as
valueType
-
readAll
Description copied from class:DeserializerReturns string representation of the variables stored in the deserializer.- Specified by:
readAllin classDeserializer- Returns:
- string containing all variables
-
readArrayOfInts
- Overrides:
readArrayOfIntsin classDeserializer
-
readBoolean
Description copied from class:DeserializerReads value with the specified name asBoolean.- Specified by:
readBooleanin classDeserializer- Parameters:
name- name of the value to read- Returns:
- the value as
Boolean
-
readInt
Description copied from class:DeserializerReads value with the specified name asint.- Specified by:
readIntin classDeserializer- Parameters:
name- name of the value to read- Returns:
- the value as
int
-
readList
Description copied from class:DeserializerReads array from root Json node.- Overrides:
readListin classDeserializer- Parameters:
valueType- type of the value to read- Returns:
- the value as
List<valueType>
-
readList
Description copied from class:DeserializerReads array with the specified name asList<valueType>.- Overrides:
readListin classDeserializer- Parameters:
name- name of the array to readvalueType- type of the value to read- Returns:
- the value as
List<valueType>
-
readListPerunBeans
Description copied from class:DeserializerReads array with the specified name asList<PerunBean>.- Overrides:
readListPerunBeansin classDeserializer- Parameters:
name- name of the array to read- Returns:
- the value as
List<PerunBean>
-
readPerunBean
Description copied from class:DeserializerReads value with the specified name asPerunBean.- Overrides:
readPerunBeanin classDeserializer- Parameters:
name- name of the value to read- Returns:
- the value as
PerunBean
-
readString
Description copied from class:DeserializerReads value with the specified name asString.- Specified by:
readStringin classDeserializer- Parameters:
name- name of the value to read- Returns:
- the value as
String
-
readUUID
Description copied from class:DeserializerReads value with the specified name asUUID.- Specified by:
readUUIDin classDeserializer- Parameters:
name- name of the value to read- Returns:
- the value as
UUID
-