iOS 12 equivalent of JSONSerialization.WritingOptions.withoutEscapingSlashes (Swift)?

Viewed 361

My code:

let json: [String: Any] = ...
request.httpBody = try JSONSerialization.data(withJSONObject: json, options: .withoutEscapingSlashes)

The problem is it works in iOS 13 only but I need to support iOS 12 too.

How to fix it correctly? Should I convert Data to String, replace "\/" with "/" and convert to Data back manually each time?

0 Answers
Related