Created
December 20, 2017 09:38
-
-
Save Burgestrand/c64f6bd43f51b1f792014b201a6aeba4 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 Foundation | |
import CoreGraphics | |
var points: [CGPoint] = [] | |
points.append(.zero) | |
points.append(CGPoint(x: 10, y: 20)) | |
let encoder = JSONEncoder() | |
let encoded = try! encoder.encode(points) | |
let json = String(data: encoded, encoding: .utf8)! | |
debugPrint(json) | |
let decoder = JSONDecoder() | |
let data = json.data(using: .utf8)! | |
let decoded = try! decoder.decode([CGPoint].self, from: data) | |
debugPrint(decoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment