Skip to content

Instantly share code, notes, and snippets.

@owensd

owensd/stringbytes.swift Secret

Created May 19, 2017
Embed
What would you like to do?
let data = string.data(using: String.Encoding.utf8, allowLossyConversion: false)!
return try data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) -> JSValue in
let buffer = UnsafeBufferPointer(start: ptr, count: data.count)
let generator = ReplayableGenerator(buffer)
let value = try parse(generator)
try validateRemainingContent(generator)
return value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.