JSONMatcher

public final class JSONMatcher : NSObject, Sendable, Codable

A matcher for evaluating a JSON payload against a set of criteria.

JSONMatcher allows you to specify conditions for a JSON value, optionally at a specific key or nested path (scope), and then evaluate if a given JSON object meets those conditions.

  • Creates a new JSONMatcher.

    Declaration

    Swift

    public convenience init(valueMatcher: JSONValueMatcher)

    Parameters

    valueMatcher

    The JSONValueMatcher to apply to the value.

    Return Value

    A new JSONMatcher instance.

  • Creates a new JSONMatcher with a specified scope.

    Declaration

    Swift

    public convenience init(valueMatcher: JSONValueMatcher, scope: [String])

    Parameters

    valueMatcher

    The JSONValueMatcher to apply to the value.

    scope

    An array of keys representing the path to the value.

    Return Value

    A new JSONMatcher instance.

  • Evaluates the given AirshipJSON value against the matcher’s criteria.

    This method traverses the JSON object using the scope and key to find the target value, then uses the valueMatcher to perform the evaluation.

    Declaration

    Swift

    public func evaluate(json: AirshipJSON) -> Bool

    Parameters

    json

    The AirshipJSON object to evaluate.

    Return Value

    true if the value matches the criteria; otherwise, false.