Skip to main content

removeEmptyValues

A Workflow Engine function that removes empty values from a JSON object. This is a generic action to remove empty values from any JSON object (for example, custom_info).

Arguments

Workflow Engine function removeEmptyValues takes the following arguments:

Name

Required

Type

Description

source

yes

string

The source object to remove values from.

destination

no

string

The destination object to write the “cleaned” object to. Defaults to the “source”.

strict

no

string (true | false)

Use “strict” mode, removing all “falsey” values. Default is “false” (0, and false are allowed values)

Examples

Given a custom_info object:

custom_info	: {
    list : [],
    object : {
		"empty" : "",
		"empty_object" : {},
		"full_object" : {
			"key1": "value1"
		}
	},
	fulllist :  [ null, 0, 1, 2, 3, "" ],
	int : 0,
	false : false,
	true : true
}
  • source: custom_info

  • destination : <leave blank to write the results back to the source “custom_info>

Example 1. strict = false

With “strict” false (either not set or set to false the resulting “cleaned” object would be:

"custom_info": {
        "false": false,
        "true": true,
        "fulllist": [
            null,
            0,
            1,
            2,
            3,
            ""
        ],
        "int": 0,
        "object": {
            "full_object": {
                "key1": "value1"
            }
        }
    }

Important

Array values are NOT examined - custom_info.fulllist contains “falsey” values - these will not be removed.



Example 2. strict = true

With “strict” true (set to true) the resulting “cleaned” object would be :

"custom_info": {
        "true": true,
        "fulllist": [
            null,
            0,
            1,
            2,
            3,
            ""
        ],
        "object": {
            "full_object": {
                "key1": "value1"
            }
        }
    }

The strict mode has removed the additional falsey values.