@@ -170,50 +170,50 @@ public void writeTo(final OutputStream out) throws IOException {
170
170
// Evaluate the value (which cannot be null).
171
171
Object value = jsonParams .get (key );
172
172
173
- // Bail out prematurely if value's null.
174
- if (value == null ) {
175
- continue ;
176
- }
177
-
178
173
// Write the JSON object's key.
179
174
os .write (escape (key ));
180
175
os .write (':' );
181
176
182
- // Check if this is a FileWrapper.
183
- isFileWrapper = value instanceof RequestParams .FileWrapper ;
184
-
185
- // If a file should be uploaded.
186
- if (isFileWrapper || value instanceof RequestParams .StreamWrapper ) {
187
- // All uploads are sent as an object containing the file's details.
188
- os .write ('{' );
177
+ // Bail out prematurely if value's null.
178
+ if (value == null ) {
179
+ os .write (JSON_NULL );
180
+ } else {
181
+ // Check if this is a FileWrapper.
182
+ isFileWrapper = value instanceof RequestParams .FileWrapper ;
183
+
184
+ // If a file should be uploaded.
185
+ if (isFileWrapper || value instanceof RequestParams .StreamWrapper ) {
186
+ // All uploads are sent as an object containing the file's details.
187
+ os .write ('{' );
188
+
189
+ // Determine how to handle this entry.
190
+ if (isFileWrapper ) {
191
+ writeToFromFile (os , (RequestParams .FileWrapper ) value );
192
+ } else {
193
+ writeToFromStream (os , (RequestParams .StreamWrapper ) value );
194
+ }
189
195
190
- // Determine how to handle this entry.
191
- if (isFileWrapper ) {
192
- writeToFromFile (os , (RequestParams .FileWrapper ) value );
196
+ // End the file's object and prepare for next one.
197
+ os .write ('}' );
198
+ } else if (value instanceof JsonValueInterface ) {
199
+ os .write (((JsonValueInterface ) value ).getEscapedJsonValue ());
200
+ } else if (value instanceof org .json .JSONObject ) {
201
+ os .write (((org .json .JSONObject ) value ).toString ().getBytes ());
202
+ } else if (value instanceof org .json .JSONArray ) {
203
+ os .write (((org .json .JSONArray ) value ).toString ().getBytes ());
204
+ } else if (value instanceof Boolean ) {
205
+ os .write ((Boolean ) value ? JSON_TRUE : JSON_FALSE );
206
+ } else if (value instanceof Long ) {
207
+ os .write ((((Number ) value ).longValue () + "" ).getBytes ());
208
+ } else if (value instanceof Double ) {
209
+ os .write ((((Number ) value ).doubleValue () + "" ).getBytes ());
210
+ } else if (value instanceof Float ) {
211
+ os .write ((((Number ) value ).floatValue () + "" ).getBytes ());
212
+ } else if (value instanceof Integer ) {
213
+ os .write ((((Number ) value ).intValue () + "" ).getBytes ());
193
214
} else {
194
- writeToFromStream ( os , ( RequestParams . StreamWrapper ) value );
215
+ os . write ( escape ( value . toString ()) );
195
216
}
196
-
197
- // End the file's object and prepare for next one.
198
- os .write ('}' );
199
- } else if (value instanceof JsonValueInterface ) {
200
- os .write (((JsonValueInterface ) value ).getEscapedJsonValue ());
201
- } else if (value instanceof org .json .JSONObject ) {
202
- os .write (((org .json .JSONObject ) value ).toString ().getBytes ());
203
- } else if (value instanceof org .json .JSONArray ) {
204
- os .write (((org .json .JSONArray ) value ).toString ().getBytes ());
205
- } else if (value instanceof Boolean ) {
206
- os .write ((Boolean ) value ? JSON_TRUE : JSON_FALSE );
207
- } else if (value instanceof Long ) {
208
- os .write ((((Number ) value ).longValue () + "" ).getBytes ());
209
- } else if (value instanceof Double ) {
210
- os .write ((((Number ) value ).doubleValue () + "" ).getBytes ());
211
- } else if (value instanceof Float ) {
212
- os .write ((((Number ) value ).floatValue () + "" ).getBytes ());
213
- } else if (value instanceof Integer ) {
214
- os .write ((((Number ) value ).intValue () + "" ).getBytes ());
215
- } else {
216
- os .write (escape (value .toString ()));
217
217
}
218
218
} finally {
219
219
// Separate each K:V with a comma, except the last one.
0 commit comments