UAJSONMatcher

@interface UAJSONMatcher : NSObject

Matcher for a JSON payload.

  • The matcher’s JSON payload.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    + (nonnull instancetype)matcherWithValueMatcher:
        (nonnull UAJSONValueMatcher *)valueMatcher;

    Swift

    convenience init(valueMatcher: UAJSONValueMatcher)

    Parameters

    valueMatcher

    Matcher to apply to the value.

    Return Value

    A JSON matcher.

  • Factory method to create a JSON matcher.

    Declaration

    Objective-C

    + (nonnull instancetype)
        matcherWithValueMatcher:(nonnull UAJSONValueMatcher *)valueMatcher
                          scope:(nonnull NSArray<NSString *> *)scope;

    Swift

    convenience init(valueMatcher: UAJSONValueMatcher, scope: [String])

    Parameters

    valueMatcher

    Matcher to apply to the value.

    scope

    Used to path into the object before evaluating the value.

    Return Value

    A JSON matcher.

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

    Declaration

    Objective-C

    + (nullable instancetype)matcherWithJSON:(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 value matcher, or nil if the JSON is invalid.

  • Evaluates the object with the matcher.

    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 matcher matches the object, otherwise NO.