@@ -85,24 +85,24 @@ export declare class JsonConvert {
8585 * Determines the rule of how JSON properties shall be matched with class properties during deserialization.
8686 *
8787 * You may assign the following values:
88- * - CASE_STRICT: JSON properties need to match exactly the names in the decorators
89- * - CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
88+ * - PropertyMatchingRule. CASE_STRICT: JSON properties need to match exactly the names in the decorators
89+ * - PropertyMatchingRule. CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
9090 */
9191 private _propertyMatchingRule ;
9292 /**
9393 * Determines the rule of how JSON properties shall be matched with class properties during deserialization.
9494 *
9595 * You may assign the following values:
96- * - CASE_STRICT: JSON properties need to match exactly the names in the decorators
97- * - CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
96+ * - PropertyMatchingRule. CASE_STRICT: JSON properties need to match exactly the names in the decorators
97+ * - PropertyMatchingRule. CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
9898 * @returns {number }
9999 */
100100 /**
101- * Determines the rule of how JSON properties shall be matched with class properties during deserialization.
101+ * Determines the rule of how JSON properties shall be matched with class properties during deserialization.
102102 *
103103 * You may assign the following values:
104- * - CASE_STRICT: JSON properties need to match exactly the names in the decorators
105- * - CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
104+ * - PropertyMatchingRule. CASE_STRICT: JSON properties need to match exactly the names in the decorators
105+ * - PropertyMatchingRule. CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
106106 * @param value
107107 */
108108 propertyMatchingRule : number ;
@@ -122,96 +122,96 @@ export declare class JsonConvert {
122122 *
123123 * @param data object or array of objects
124124 *
125- * @returns { any } the JSON object
125+ * @returns the JSON object
126126 *
127- * @throws an exception in case of failure
127+ * @throws an Error in case of failure
128128 *
129129 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
130130 * @see https://www.npmjs.com/package/json2typescript full documentation
131131 */
132- serialize ( data : any ) : any ;
132+ serialize < T > ( data : T | T [ ] ) : any | any [ ] ;
133133 /**
134134 * Tries to serialize a TypeScript object to a JSON object.
135135 *
136136 * @param instance TypeScript instance
137137 *
138- * @returns { any } the JSON object
138+ * @returns the JSON object
139139 *
140- * @throws an exception in case of failure
140+ * @throws an Error in case of failure
141141 *
142142 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
143143 * @see https://www.npmjs.com/package/json2typescript full documentation
144144 */
145- serializeObject ( instance : any ) : any ;
145+ serializeObject < T > ( instance : T ) : any ;
146146 /**
147147 * Tries to serialize a TypeScript array to a JSON array.
148148 *
149149 * @param instanceArray array of TypeScript instances
150150 *
151- * @returns { any[] } the JSON array
151+ * @returns the JSON array
152152 *
153- * @throws an exception in case of failure
153+ * @throws an Error in case of failure
154154 *
155155 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
156156 * @see https://www.npmjs.com/package/json2typescript full documentation
157157 */
158- serializeArray ( instanceArray : any [ ] ) : any [ ] ;
158+ serializeArray < T > ( instanceArray : T [ ] ) : any [ ] ;
159159 /**
160160 * Tries to deserialize given JSON to a TypeScript object or array of objects.
161161 *
162162 * @param json the JSON as object or array
163163 * @param classReference the class reference
164164 *
165- * @returns { any } the deserialized data (TypeScript instance or array of TypeScript instances)
165+ * @returns the deserialized data (TypeScript instance or array of TypeScript instances)
166166 *
167- * @throws an exception in case of failure
167+ * @throws an Error in case of failure
168168 *
169169 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
170170 * @see https://www.npmjs.com/package/json2typescript full documentation
171171 */
172- deserialize ( json : any , classReference : {
173- new ( ) : any ;
174- } ) : any ;
172+ deserialize < T > ( json : any , classReference : {
173+ new ( ) : T ;
174+ } ) : T | T [ ] ;
175175 /**
176176 * Tries to deserialize a JSON object to a TypeScript object.
177177 *
178178 * @param jsonObject the JSON object
179179 * @param classReference the class reference
180180 *
181- * @returns { any } the deserialized TypeScript instance
181+ * @returns the deserialized TypeScript instance
182182 *
183- * @throws an exception in case of failure
183+ * @throws an Error in case of failure
184184 *
185185 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
186186 * @see https://www.npmjs.com/package/json2typescript full documentation
187187 */
188- deserializeObject ( jsonObject : any , classReference : {
189- new ( ) : any ;
190- } ) : any ;
188+ deserializeObject < T > ( jsonObject : any , classReference : {
189+ new ( ) : T ;
190+ } ) : T ;
191191 /**
192192 * Tries to deserialize a JSON array to a TypeScript array.
193193 *
194194 * @param jsonArray the JSON array
195195 * @param classReference the object class
196196 *
197- * @returns { any[] } the deserialized array of TypeScript instances
197+ * @returns the deserialized array of TypeScript instances
198198 *
199- * @throws an exception in case of failure
199+ * @throws an Error in case of failure
200200 *
201201 * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
202202 * @see https://www.npmjs.com/package/json2typescript full documentation
203203 */
204- deserializeArray ( jsonArray : any [ ] , classReference : {
205- new ( ) : any ;
206- } ) : any [ ] ;
204+ deserializeArray < T > ( jsonArray : any [ ] , classReference : {
205+ new ( ) : T ;
206+ } ) : T [ ] ;
207207 /**
208208 * Tries to find the JSON mapping for a given class property and finally assign the value.
209209 *
210210 * @param instance the instance of the class
211211 * @param classPropertyName the property name
212212 * @param json the JSON object
213213 *
214- * @throws throws an expection in case of failure
214+ * @throws throws an Error in case of failure
215215 */
216216 private serializeObject_loopProperty ;
217217 /**
@@ -221,7 +221,7 @@ export declare class JsonConvert {
221221 * @param classPropertyName the property name
222222 * @param json the JSON object
223223 *
224- * @throws throws an expection in case of failure
224+ * @throws throws an Error in case of failure
225225 */
226226 private deserializeObject_loopProperty ;
227227 /**
@@ -243,9 +243,21 @@ export declare class JsonConvert {
243243 *
244244 * @returns returns the resulted mapped property
245245 *
246- * @throws throws an expection in case of failure
246+ * @throws an error in case of failure
247247 */
248248 private verifyProperty ;
249+ /**
250+ * Gets the value of an object for a given value.
251+ * If the object does not have the specific key, an Error is thrown.
252+ *
253+ * @param data
254+ * @param key
255+ *
256+ * @returns returns the value
257+ *
258+ * @throws an Error in case of the key was not found in the object
259+ */
260+ private getObjectValue ;
249261 /**
250262 * Returns a string representation of the expected json type.
251263 *
0 commit comments