For example I have a json
var json = JSON(data: data!)
inside it I reference to object
var list = json["OBJECT"]
is there a way, that I can check if it is an object, or array, or string and return bool ?
This doesnt help. var list
will always be type of JSON
. And I want to find a way to check what is inside.
The JSON objects in SwiftyJSON have a type
property whose type is an enum
public enum Type: Int {
case number
case string
case bool
case array
case dictionary
case null
case unknown
}
For example
var list = json["OBJECT"]
switch list.type {
case .array: print("list is Array")
case .dictionary: print("list is Dictionary")
default: break
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With