JSONValueMatcher

@objc(UAJSONValueMatcher)
public final class JSONValueMatcher : NSObject, @unchecked Sendable

Defines a JSON value matcher.

  • The matcher’s JSON payload.

    Declaration

    Swift

    @objc
    public func payload() -> [String : Any]
  • Evaluates the object with the matcher.

    Declaration

    Swift

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

    Parameters

    value

    The object to evaluate.

    Return Value

    true if the matcher matches the object, otherwise false.

  • Evaluates the object with the matcher.

    Declaration

    Swift

    @objc(evaluateObject:ignoreCase:)
    public func evaluate(_ value: Any?, ignoreCase: Bool) -> Bool

    Parameters

    value

    The object to evaluate.

    ignoreCase

    YES to ignore case when checking String values, NO to check case. Strings contained in arrays and dictionaries also follow this rule.

    Return Value

    true if the matcher matches the object, otherwise false.

  • Factory method to create a matcher for a number that is at least the specified number.

    Declaration

    Swift

    @objc(matcherWhereNumberAtLeast:)
    public class func matcherWhereNumberAtLeast(atLeast number: NSNumber)
        -> JSONValueMatcher

    Parameters

    number

    The lower bound for the number.

    Return Value

    A value matcher.

  • Factory method to create a matcher for a number between the lowerNumber and higherNumber.

    Declaration

    Swift

    @objc(matcherWhereNumberAtLeast:atMost:)
    public class func matcherWhereNumberAtLeast(
        atLeast lowerNumber: NSNumber,
        atMost higherNumber: NSNumber
    ) -> JSONValueMatcher

    Parameters

    lowerNumber

    The lower bound for the number.

    higherNumber

    The upper bound for the number.

    Return Value

    A value matcher.

  • Factory method to create a matcher for a number that is at most the specified number.

    Declaration

    Swift

    @objc(matcherWhereNumberAtMost:)
    public class func matcherWhereNumberAtMost(atMost number: NSNumber)
        -> JSONValueMatcher

    Parameters

    number

    The upper bound for the number.

    Return Value

    A value matcher.

  • Factory method to create a matcher for an exact number.

    Declaration

    Swift

    @objc(matcherWhereNumberEquals:)
    public class func matcherWhereNumberEquals(_ number: NSNumber)
        -> JSONValueMatcher

    Parameters

    number

    The expected number value.

    Return Value

    A value matcher.

  • Factory method to create a matcher for an exact boolean.

    Declaration

    Swift

    @objc(matcherWhereBooleanEquals:)
    public class func matcherWhereBooleanEquals(_ boolean: Bool)
        -> JSONValueMatcher

    Parameters

    boolean

    The expected boolean value.

    Return Value

    A value matcher.

  • Factory method to create a matcher for an exact string.

    Declaration

    Swift

    @objc(matcherWhereStringEquals:)
    public class func matcherWhereStringEquals(_ string: String)
        -> JSONValueMatcher

    Parameters

    string

    The expected string value.

    Return Value

    A value matcher.

  • Factory method to create a matcher for the presence of a value.

    Declaration

    Swift

    @objc(matcherWhereValueIsPresent:)
    public class func matcherWhereValueIsPresent(_ present: Bool)
        -> JSONValueMatcher

    Parameters

    present

    true if the value must be present, otherwise false.

    Return Value

    A value matcher.

  • Factory method to create a matcher for a version constraint.

    Declaration

    Swift

    @objc(matcherWithVersionConstraint:)
    public class func matcherWithVersionConstraint(_ versionConstraint: String)
        -> JSONValueMatcher?

    Return Value

    A value matcher.

  • Factory method to create a matcher for an array value.

    Declaration

    Swift

    @objc(matcherWithArrayContainsPredicate:)
    public class func matcherWithArrayContainsPredicate(
        _ predicate: JSONPredicate
    ) -> JSONValueMatcher?

    Return Value

    A value matcher.

  • Factory method to create a matcher for a value in an array.

    Declaration

    Swift

    @objc(matcherWithArrayContainsPredicate:atIndex:)
    public class func matcherWithArrayContainsPredicate(
        _ predicate: JSONPredicate,
        at index: Int
    ) -> JSONValueMatcher?

    Return Value

    A value matcher.

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

    Declaration

    Swift

    @objc(matcherWithJSON:error:)
    public class func matcherWithJSON(_ json: Any?) throws -> JSONValueMatcher

    Return Value

    A value matcher, or nil if the JSON is invalid.