Created
October 1, 2017 08:58
-
-
Save dral3x/55f1c25d639ac1f792412a78a7ee7b4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var output = [String: Any]() | |
for index in 0..<5 { | |
let mail = String(format: "%d@mail.com", index) | |
let name = String(format: "name_%d", index) | |
let id = NSNumber.init(value: index) | |
let item: [String: Any] = ["name": name, "id": id] | |
output[mail] = item | |
} | |
let jsonData = try? JSONSerialization.data(withJSONObject: output, options: .prettyPrinted) | |
let jsonString = String(data: jsonData!, encoding: String.Encoding.utf8) | |
print(jsonString!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment