JSONPredicate
public final class JSONPredicate : NSObject, Sendable, Codable
Defines a predicate for evaluating a JSON payload.
JSONPredicate
can be used to build complex logical conditions (AND
, OR
, NOT
)
composed of multiple JSONMatcher
objects.
-
Creates a new predicate from a JSON payload.
Throws
An error if the JSON is invalid or cannot be decoded.Declaration
Swift
public convenience init(json: Any?) throws
Parameters
json
The JSON payload representing the predicate.
-
Evaluates the given
AirshipJSON
value against the predicate.Declaration
Swift
public func evaluate(json: AirshipJSON) -> Bool
Parameters
json
The
AirshipJSON
object to evaluate.Return Value
true
if the value matches the predicate; otherwise,false
. -
Creates a predicate from a
JSONMatcher
.Declaration
Swift
public convenience init(jsonMatcher matcher: JSONMatcher)
Parameters
matcher
The
JSONMatcher
to base the predicate on. -
Creates a predicate by AND-ing an array of sub-predicates.
Declaration
Swift
public class func andPredicate(subpredicates: [JSONPredicate]) -> JSONPredicate
Parameters
subpredicates
An array of predicates to combine.
Return Value
A new
JSONPredicate
instance. -
Creates a predicate by OR-ing an array of sub-predicates.
Declaration
Swift
public class func orPredicate(subpredicates: [JSONPredicate]) -> JSONPredicate
Parameters
subpredicates
An array of predicates to combine.
Return Value
A new
JSONPredicate
instance. -
Creates a predicate by NOT-ing a single sub-predicate.
Declaration
Swift
public class func notPredicate(subpredicate: JSONPredicate) -> JSONPredicate
Parameters
subpredicate
The predicate to negate.
Return Value
A new
JSONPredicate
instance.