Created
May 2, 2022 15:29
-
-
Save fitomad/5698fce4784a670244eef95bcf5a4759 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
let steveDocument = """ | |
{ "key" : 2, "company": "Apple" } | |
""" | |
.data(using: .utf8)! | |
let billDocument = """ | |
{ "key" : 1, "company": "Microsoft" } | |
""" | |
.data(using: .utf8)! | |
public struct Plain: Codable | |
{ | |
public var key: Int | |
public var company: String | |
} | |
var dataFrame = DataFrame() | |
let columnName = Column(ColumnID("Name", String.self), contents: [ "Steve", "Bill" ]) | |
let columnJSON = Column(ColumnID("Document", Data.self), contents: [ steveDocument, billDocument ]) | |
dataFrame.append(column: columnName) | |
dataFrame.append(column: columnJSON) | |
print(dataFrame) | |
try dataFrame.decode(Plain.self, inColumn: "Document", using: JSONDecoder()) | |
print(dataFrame) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment