UAJSONPredicate

@interface UAJSONPredicate : NSObject

Predicate for JSON payloads.

  • The predicate’s JSON payload.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSDictionary *_Nonnull payload;

    Swift

    var payload: [AnyHashable : Any] { get }
  • Factory method to create a JSON predicate from a UAJSONMatcher.

    Declaration

    Objective-C

    + (nonnull instancetype)predicateWithJSONMatcher:
        (nonnull UAJSONMatcher *)matcher;

    Swift

    convenience init(jsonMatcher matcher: UAJSONMatcher)

    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

    Objective-C

    + (nonnull instancetype)andPredicateWithSubpredicates:
        (nonnull NSArray<UAJSONPredicate *> *)subpredicates;

    Swift

    class func andPredicate(withSubpredicates subpredicates: [UAJSONPredicate]) -> Self

    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

    Objective-C

    + (nonnull instancetype)orPredicateWithSubpredicates:
        (nonnull NSArray<UAJSONPredicate *> *)subpredicates;

    Swift

    class func orPredicate(withSubpredicates subpredicates: [UAJSONPredicate]) -> Self

    Parameters

    subpredicates

    An array of predicates.

    Return Value

    A JSON predicate.

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

    Declaration

    Objective-C

    + (nonnull instancetype)notPredicateWithSubpredicate:
        (nonnull UAJSONPredicate *)subpredicate;

    Swift

    class func notPredicate(withSubpredicate subpredicate: UAJSONPredicate) -> Self

    Parameters

    subpredicate

    A predicate.

    Return Value

    A JSON predicate.

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

    Declaration

    Objective-C

    + (nullable instancetype)predicateWithJSON:(nonnull id)json
                                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    convenience init(json: Any) throws

    Parameters

    json

    The JSON payload.

    error

    An NSError pointer for storing errors, if applicable.

    Return Value

    A predicate or nil if the JSON is invalid.

  • Evaluates the object with the predicate.

    Declaration

    Objective-C

    - (BOOL)evaluateObject:(nullable id)object;

    Swift

    func evaluateObject(_ object: Any?) -> Bool

    Parameters

    object

    The object to evaluate.

    Return Value

    YES if the predicate matches the object, otherwise NO.