JSONPredicate

@objc(UAJSONPredicate)
public final class JSONPredicate : NSObject, Sendable, Codable

Predicate for JSON payloads.

  • Factory method to create a predicate from a JSON payload.

    Declaration

    Swift

    @objc(initWithJSON:error:)
    public convenience init(json: Any?) throws

    Return Value

    A predicate or nil if the JSON is invalid.

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Declaration

    Swift

    public convenience init(from decoder: Decoder) throws
  • Gets the predicate’s JSON payload.

    Declaration

    Swift

    @objc
    public func payload() -> [String : Any]

    Return Value

    The predicate’s JSON payload.

  • Evaluates the object with the predicate.

    Declaration

    Swift

    @objc(evaluateObject:)
    public func evaluate(_ object: Any?) -> Bool

    Parameters

    object

    The object to evaluate.

    Return Value

    true if the predicate matches the object, otherwise false.

  • Creates a JSON predicate from a JSONMatcher.

    Declaration

    Swift

    @objc(initWithJSONMatcher:)
    public convenience init(jsonMatcher matcher: JSONMatcher?)

    Parameters

    matcher

    A JSON matcher.

    Return Value

    A JSON predicate.

  • Factory method to create a JSON predicate formed by AND-ing an array of predicates.

    Declaration

    Swift

    @objc(andPredicateWithSubpredicates:)
    public class func andPredicate(subpredicates: [JSONPredicate]?)
        -> JSONPredicate

    Parameters

    subpredicates

    An array of predicates.

    Return Value

    A JSON predicate.

  • Factory method to create a JSON predicate formed by OR-ing an array of predicates.

    Declaration

    Swift

    @objc(orPredicateWithSubpredicates:)
    public class func orPredicate(subpredicates: [JSONPredicate]?)
        -> JSONPredicate

    Parameters

    subpredicates

    An array of predicates.

    Return Value

    A JSON predicate.

  • Factory method to create a JSON predicate by NOT-ing a predicate.

    Declaration

    Swift

    @objc(notPredicateWithSubpredicate:)
    public class func notPredicate(subpredicate: JSONPredicate) -> JSONPredicate

    Parameters

    subpredicate

    A predicate.

    Return Value

    A JSON predicate.