Skip to content

Type Property

withoutEscapingSlashes

iOS 13.0+ iPadOS 13.0+ Mac Catalyst 13.0+ macOS 10.15+ tvOS 13.0+ watchOS 6.0+
The output formatting option specifies that the output doesn’t prefix slash characters with escape characters.
static let withoutEscapingSlashes: JSONEncoder.OutputFormatting

Discussion

By default slashes get escaped (”/” -> “/”, “http://apple.com/” -> “http://apple.com/”) for security reasons, allowing outputted JSON to be safely embedded within HTML/XML. In contexts where this escaping is unnecessary, the JSON is known to not be embedded, or is intended only for display, this option avoids this escaping.