Skip to content

Instantly share code, notes, and snippets.

@sergiosette
Created October 17, 2017 19:51
Show Gist options
  • Save sergiosette/be74ab5f17f1f09d0d91ef59c2f3ecdd to your computer and use it in GitHub Desktop.
Save sergiosette/be74ab5f17f1f09d0d91ef59c2f3ecdd to your computer and use it in GitHub Desktop.
func parse(_ json: String) -> Any? {
return Bool(json) ?? Int(json) ?? Double(json) ?? parseString(json)
}
private func parseString(_ text: String) -> String? {
switch (text.first, text.last) {
case ("\""?, "\""?): return ""
default: return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment