Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fake URL + url encoded query paramaters
import Foundation
let encodedString = "data=%7B%0D%0A%22coffee%22%3A%20%22coffee%22%2C%0D%0A%22beer%22%3A%20%22beer%22%2C%0D%0A%22has_bylaws%22%3A%20true%0D%0A%7D%0D%0A"
guard let c = URLComponents(string: "" + encodedString) else {
fatalError("could not generate url components! :(")
for item in c.queryItems ?? [] {
print("Got key \( with value \(item.value)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment