Created
October 17, 2017 19:51
-
-
Save sergiosette/be74ab5f17f1f09d0d91ef59c2f3ecdd 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 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