Share

Check if an Object is a Dictionary Object

Definition: isDict(value: object) → boolean
Description: Checks if an object is a dictionary
Parameters: value: The object to be tested
Returns: True if the input object is a dictionary; otherwise, returns False

The following script checks if the value of the <field_name> field is a dictionary, using the isDict function. It then assigns the returned boolean response to the <is_field_a_dict> field.

Note: Replace the placeholder values in the script with your own.

from io.hevo.api import Event
from io.hevo.api import Utils

def transform(event):
    eventName = event.getEventName()
    properties = event.getProperties()

    <is_field_a_dict> = Utils.isDict(properties['<field_name>'])

Sample Transformation

The following script checks if the value of the address field is a dictionary and displays the boolean value true in the is_address_array field.

from io.hevo.api import Event
from io.hevo.api import Utils


def transform(event):
    properties = event.getProperties()

    is_address_array = Utils.isDict(properties['address'])
    properties['is_address_array'] = is_address_array

    return event

Sample Output

The boolean value true is displayed in the is_address_array field.

Sample Output - Check if an Object is a Dictionary Object


Last updated on Jun 30, 2023

Tell us what went wrong

Skip to the section