Created
September 25, 2020 19:45
-
-
Save regularberry/f1d7e9afef8aff4d63493a0ba12d1b56 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
func printJSON() { | |
let rootContext = Context( | |
data: Context.Data( | |
displayOrder: 0, | |
identifierPath: [Bundle.main.bundleIdentifier ?? ""], | |
isAssignable: false, | |
progressReportingCapabilities: [], | |
summary: "Fun tapper games for math and writing!", | |
title: "EduJam", | |
topic: "", | |
type: "app" | |
), | |
metadata: Context.Metadata( | |
keywords: ["math", "writing", "game"] | |
) | |
) | |
let gameContexts: [Context] = // convert your activities to the JSON-friendly Context | |
let node = ContextsRequest(contexts: [rootContext] + gameContexts) | |
let encoder = JSONEncoder() | |
encoder.outputFormatting = .prettyPrinted | |
let jsonData = (try? encoder.encode(node)) ?? Data() | |
let jsonStr = String(data: jsonData, encoding: .utf8) ?? "" | |
print(jsonStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment