Skip to main content
Version: Next

Omit Object By Predicate

Excludes properties from the object using 'Predicate'

Description

The idea of the brick is to return a list free of certain items. Which items to omit is decided in the 'Predicate'. The 'Predicate' is a function that will be applied to each item in the list.

Example:

  • inputs

    • Source = { "a": 1, "b": "user", "c": 3 }
    • Predicate = value => 'Is Not a Number'
  • outputs

    • result = { "a": "1", "c":"3" }

In the example, the brick looks at the object's "Source" and then looks at the 'Predicate'. Since the 'Predicate' allows only values that are not a number, the objects the value of which is not a number will be taken out and the brick will return a new object as 'Result'.

Inputs

  • Source (Object): JSON object or string
  • Predicate (Object Iteratee): The predicate function is invoked for each entry (key, value).
    Inputs:
    - key (string): The current property of the object.
    - value (object): The properties' value.
    - object (Object): The current object.

    Outputs:
    -Result (Boolean): Should the result include the property or not? Set it to true if the property should be omitted, false if you do not want the property

Outputs

  • Result (Object): The new updated object
  • Error Flow (Error Flow): Triggered by providing incorrect json