88import java .util .ArrayList ;
99import java .util .Date ;
1010import java .util .List ;
11+ import java .util .Map ;
1112import java .util .TimeZone ;
1213
1314import javax .ws .rs .Produces ;
2324import com .fasterxml .jackson .core .JsonParseException ;
2425import com .fasterxml .jackson .core .JsonParser ;
2526import com .fasterxml .jackson .core .JsonProcessingException ;
27+ import com .fasterxml .jackson .core .type .TypeReference ;
2628import com .fasterxml .jackson .databind .DeserializationContext ;
2729import com .fasterxml .jackson .databind .DeserializationFeature ;
2830import com .fasterxml .jackson .databind .JsonDeserializer ;
@@ -87,12 +89,12 @@ public ObjectMapper getObjectMapper() {
8789
8890 /**
8991 * Unmarshal the JSON data on the specified Reader instance to an instance of the provided class.
90- *
92+ *
9193 * @param <T> the generics type for the return value
9294 * @param returnType an instance of this type class will be returned
9395 * @param reader the Reader instance that contains the JSON data
9496 * @return an instance of the provided class containing the parsed data from the Reader
95- * @throws JsonParseException when an error occurs paresing the provided JSON
97+ * @throws JsonParseException when an error occurs parsing the provided JSON
9698 * @throws JsonMappingException if a JSON error occurs
9799 * @throws IOException if an error occurs reading the JSON data
98100 */
@@ -103,12 +105,12 @@ public <T> T unmarshal(Class<T> returnType, Reader reader) throws JsonParseExcep
103105
104106 /**
105107 * Unmarshal the JSON data contained by the string and populate an instance of the provided returnType class.
106- *
108+ *
107109 * @param <T> the generics type for the return value
108110 * @param returnType an instance of this type class will be returned
109111 * @param postData a String holding the POST data
110112 * @return an instance of the provided class containing the parsed data from the string
111- * @throws JsonParseException when an error occurs paresing the provided JSON
113+ * @throws JsonParseException when an error occurs parsing the provided JSON
112114 * @throws JsonMappingException if a JSON error occurs
113115 * @throws IOException if an error occurs reading the JSON data
114116 */
@@ -117,6 +119,70 @@ public <T> T unmarshal(Class<T> returnType, String postData) throws JsonParseExc
117119 return (objectMapper .readValue (postData , returnType ));
118120 }
119121
122+ /**
123+ * Unmarshal the JSON data on the specified Reader instance and populate a List of instances of the provided returnType class.
124+ *
125+ * @param <T> the generics type for the List
126+ * @param returnType an instance of this type class will be contained in the returned List
127+ * @param reader the Reader instance that contains the JSON data
128+ * @return a List of the provided class containing the parsed data from the Reader
129+ * @throws JsonParseException when an error occurs parsing the provided JSON
130+ * @throws JsonMappingException if a JSON error occurs
131+ * @throws IOException if an error occurs reading the JSON data
132+ */
133+ public <T > List <T > unmarshalList (Class <T > returnType , Reader reader ) throws JsonParseException , JsonMappingException , IOException {
134+ ObjectMapper objectMapper = getContext (null );
135+ return (objectMapper .readValue (reader , new TypeReference <List <T >>() {}));
136+ }
137+
138+ /**
139+ * Unmarshal the JSON data contained by the string and populate a List of instances of the provided returnType class.
140+ *
141+ * @param <T> the generics type for the List
142+ * @param returnType an instance of this type class will be contained in the returned List
143+ * @param postData a String holding the POST data
144+ * @return a List of the provided class containing the parsed data from the string
145+ * @throws JsonParseException when an error occurs parsing the provided JSON
146+ * @throws JsonMappingException if a JSON error occurs
147+ * @throws IOException if an error occurs reading the JSON data
148+ */
149+ public <T > List <T > unmarshalList (Class <T > returnType , String postData ) throws JsonParseException , JsonMappingException , IOException {
150+ ObjectMapper objectMapper = getContext (null );
151+ return objectMapper .readValue (postData , new TypeReference <List <T >>() {});
152+ }
153+
154+ /**
155+ * Unmarshal the JSON data on the specified Reader instance and populate a Map of String keys and values of the provided returnType class.
156+ *
157+ * @param <T> the generics type for the Map value
158+ * @param returnType an instance of this type class will be contained the values of the Map
159+ * @param reader the Reader instance that contains the JSON data
160+ * @return a Map containing the parsed data from the Reader
161+ * @throws JsonParseException when an error occurs parsing the provided JSON
162+ * @throws JsonMappingException if a JSON error occurs
163+ * @throws IOException if an error occurs reading the JSON data
164+ */
165+ public <T > Map <String , T > unmarshalMap (Class <T > returnType , Reader reader ) throws JsonParseException , JsonMappingException , IOException {
166+ ObjectMapper objectMapper = getContext (null );
167+ return (objectMapper .readValue (reader , new TypeReference <Map <String , T >>() {}));
168+ }
169+
170+ /**
171+ * Unmarshal the JSON data and populate a Map of String keys and values of the provided returnType class.
172+ *
173+ * @param <T> the generics type for the Map value
174+ * @param returnType an instance of this type class will be contained the values of the Map
175+ * @param jsonData the String containing the JSON data
176+ * @return a Map containing the parsed data from the String
177+ * @throws JsonParseException when an error occurs parsing the provided JSON
178+ * @throws JsonMappingException if a JSON error occurs
179+ * @throws IOException if an error occurs reading the JSON data
180+ */
181+ public <T > Map <String , T > unmarshalMap (Class <T > returnType , String jsonData ) throws JsonParseException , JsonMappingException , IOException {
182+ ObjectMapper objectMapper = getContext (null );
183+ return (objectMapper .readValue (jsonData , new TypeReference <Map <String , T >>() {}));
184+ }
185+
120186 /**
121187 * Marshals the supplied object out as a formatted JSON string.
122188 *
0 commit comments