Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created June 15, 2018 08:09
Show Gist options
  • Save onmyway133/81c6578ce5f77c6f571a774e6b025359 to your computer and use it in GitHub Desktop.
Save onmyway133/81c6578ce5f77c6f571a774e6b025359 to your computer and use it in GitHub Desktop.
/**
Helper enum to work with JSON arrays and dictionaries.
*/
public enum JSON {
/// JSON array
case array([Any])
/// JSON dictionary
case dictionary([String : Any])
/// Converts value to Any
public var object: Any {
switch self {
case .array(let object):
return object
case .dictionary(let object):
return object
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment