File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -426,7 +426,28 @@ open class Client {
426
426
_ request: inout HTTPClientRequest ,
427
427
with params: [String: Any ?] = [:]
428
428
) throws {
429
- let json = try JSONSerialization .data (withJSONObject: params , options: [])
429
+ var encodedParams = [String:Any ]()
430
+
431
+ for (key , param ) in params {
432
+ if param is String
433
+ || param is Int
434
+ || param is Float
435
+ || param is Bool
436
+ || param is [String ]
437
+ || param is [Int ]
438
+ || param is [Float ]
439
+ || param is [Bool ]
440
+ || param is [String: Any ]
441
+ || param is [Int: Any ]
442
+ || param is [Float: Any ]
443
+ || param is [Bool: Any ]
444
+ encodedParams [key ] = param
445
+ } else {
446
+ encodedParams [key ] = try ! (param as ! Encodable ).toJson ()
447
+ }
448
+ }
449
+
450
+ let json = try JSONSerialization .data (withJSONObject: encodedParams , options: [])
430
451
431
452
request .body = .bytes (json )
432
453
}
You can’t perform that action at this time.
0 commit comments