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
ConstructorDescriptionJsonDeserializer
(jakarta.servlet.http.HttpServletRequest request) Create deserializer for JSON/JSONP data format. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if value with the specified name is supplied.jakarta.servlet.http.HttpServletRequest
Return HttpServletRequest related to concrete call this deserializer is used to process.<T> T
Reads value from root Json node.<T> T
Reads 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
.int
Reads 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 ofin
is wrongly formatted
-
JsonDeserializer
- Throws:
IOException
-
-
Method Details
-
contains
Description copied from class:Deserializer
Returnstrue
if value with the specified name is supplied.- Specified by:
contains
in classDeserializer
- Parameters:
name
- name of the value to check- Returns:
true
if value with the specified name is supplied,false
otherwise
-
getServletRequest
public jakarta.servlet.http.HttpServletRequest getServletRequest()Description copied from class:Deserializer
Return 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:
getServletRequest
in classDeserializer
- Returns:
- HttpServletRequest related to concrete call
-
read
Description copied from class:Deserializer
Reads value from root Json node.- Overrides:
read
in classDeserializer
- Parameters:
valueType
- type of the value to read- Returns:
- the value as
valueType
-
read
Description copied from class:Deserializer
Reads value with the specified name asvalueType
.- Overrides:
read
in 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:Deserializer
Returns string representation of the variables stored in the deserializer.- Specified by:
readAll
in classDeserializer
- Returns:
- string containing all variables
-
readArrayOfInts
- Overrides:
readArrayOfInts
in classDeserializer
-
readBoolean
Description copied from class:Deserializer
Reads value with the specified name asBoolean
.- Specified by:
readBoolean
in classDeserializer
- Parameters:
name
- name of the value to read- Returns:
- the value as
Boolean
-
readInt
Description copied from class:Deserializer
Reads value with the specified name asint
.- Specified by:
readInt
in classDeserializer
- Parameters:
name
- name of the value to read- Returns:
- the value as
int
-
readList
Description copied from class:Deserializer
Reads array from root Json node.- Overrides:
readList
in classDeserializer
- Parameters:
valueType
- type of the value to read- Returns:
- the value as
List<valueType>
-
readList
Description copied from class:Deserializer
Reads array with the specified name asList<valueType>
.- Overrides:
readList
in 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:Deserializer
Reads array with the specified name asList<PerunBean>
.- Overrides:
readListPerunBeans
in classDeserializer
- Parameters:
name
- name of the array to read- Returns:
- the value as
List<PerunBean>
-
readPerunBean
Description copied from class:Deserializer
Reads value with the specified name asPerunBean
.- Overrides:
readPerunBean
in classDeserializer
- Parameters:
name
- name of the value to read- Returns:
- the value as
PerunBean
-
readString
Description copied from class:Deserializer
Reads value with the specified name asString
.- Specified by:
readString
in classDeserializer
- Parameters:
name
- name of the value to read- Returns:
- the value as
String
-
readUUID
Description copied from class:Deserializer
Reads value with the specified name asUUID
.- Specified by:
readUUID
in classDeserializer
- Parameters:
name
- name of the value to read- Returns:
- the value as
UUID
-