init(json:)
Creates equivalent content from a JSON string.
Declaration
init(json: String) throwsDiscussion
The JSON string you provide may be incomplete. This is useful for correctly handling partially generated responses.
@Generable struct NovelIdea {
let title: String
}
let partial = #"{"title": "A story of"#
let content = try GeneratedContent(json: partial)
let idea = try NovelIdea(content)
print(idea.title) // A story of