# Miscellaneous functions

This page describes the additional set of predefined Jsonnet functions for the [Data Transformer Script](https://docs.cloud.google.com/application-integration/docs/configure-data-transformer-script-task.md.txt) task available in Application Integration.

### Before you begin


To use the following predefined functions, you must import the `functions` library in your script. Importing the `functions` library lets you use both the standard Jsonnet functions and the predefined **Data Transformer** functions.


Application Integration supports Jsonnet functions library v0.20.0. For information about the Jsonnet standard functions, see [Jsonnet Standard Library](https://jsonnet.org/ref/stdlib.html).

> [!NOTE]
> **Note:** Throughout this page, the term "**object field** " or "**field** " refers specifically to a **JSON key**. For example, in the JSON object \`{"firstName": "John"}\`, \`"firstName"\` represents an object field (or JSON key).

### `Type`

| Syntax | ```html type(value) ``` |
| Description | Identifies the data type of the input value. |
| Input parameter | **value:** The input value. This can be a string, boolean, integer, object, or function. |
| Return type | `STRING` |
| Output | Returns a string indicating the data type of the input value. |
|---|---|

*** ** * ** ***

### `Length`

| Syntax | ```html length(value) ``` |
| Description | Calculates the length of the input value. |
| Input parameter | **value:** The input value. This can be a string, array, or object. |
| Return type | `INTEGER` |
| Output | Returns the length of the input value based on its data type. Throws an error if the data type is not supported. |
|---|---|

*** ** * ** ***

### `Get`

| Syntax | ```html get(object, field, default, includeHidden) ``` |
| Description | Retrieves the value of a specified field from an object. |
| Input parameter | - **object:** The input JSON object. - **field:** The name of the field to retrieve. - **default:** The default value to return if the field does not exist. - **includeHidden:** A boolean indicating whether to include hidden fields in the search. > [!NOTE] > **Note:** Set the `includedHidden` parameter to `true` to include hidden fields in the search. |
| Return type | The data type of the object field, or the data type of the default value if the field does not exist. |
| Output | Returns the value of the specified field from the input object. If the field is not present, it returns the default value. |
|---|---|

*** ** * ** ***

### `Has`

| Syntax | ```html has(object, field) ``` |
| Description | Checks if a specified field exists in an object. |
| Input parameter | - **object:** The input JSON object. - **field:** The name of the field to check for existence. |
| Return type | `BOOLEAN` |
| Output | Returns `true` if the given object has the specified field; otherwise, returns `false`. |
|---|---|

*** ** * ** ***

### `Object Fields`

| Syntax | ```html objectFields(object) ``` |
| Description | Extracts the names of all fields from an object. |
| Input parameter | **object:** The input JSON object. |
| Return type | `ARRAY` |
| Output | Returns an array containing the names of all fields specified in the input object. |
|---|---|

*** ** * ** ***

### `Object Values`

| Syntax | ```html objectValues(object) ``` |
| Description | Extracts the values of all fields from an object. |
| Input parameter | **object:** The input JSON object. |
| Return type | `ARRAY` |
| Output | Returns an array containing all the values of fields specified in the input object. |
|---|---|

*** ** * ** ***

### `Object Keys Values`

| Syntax | ```html objectKeysValues(object) ``` |
| Description | Extracts all fields of the input object and organizes them into an array, with each element containing a key-value pair. |
| Input parameter | **object:** The input JSON object. |
| Return type | `ARRAY` |
| Output | Returns an array of objects from the input object, where each object has two fields: `key` (`STRING`) and `value` (`OBJECT`). The output does not include hidden fields. |
|---|---|

*** ** * ** ***

### `Prune`

| Syntax | ```html prune(data) ``` |
| Description | Removes all empty members of the data. "Empty" is defined as zero length or null. |
| Input parameter | **data:** The input data to be pruned, which can be a string, object, or array. |
| Return type | `OBJECT/ARRAY/STRING` |
| Output | Returns the input data with all empty members (zero length or null) removed. |
|---|---|

*** ** * ** ***

### `Map with Key`

| Syntax | ```html mapWithKey(function, object) ``` |
| Description | Transforms each key-value pair in the input object using the specified function. For example, if the specified function is `concat`, the result is a new object where each key-value pair is transformed such that the value becomes a concatenation of the key and value (`{key: "value"}` becomes `{key: "key:value"}`). |
| Input parameter | - **function:** The function that transforms each key-value pair. - **object:** The input JSON object to transform. |
| Return type | `OBJECT` |
| Output | Returns a new object with each key-value pair transformed according to the provided function. |
|---|---|

*** ** * ** ***

### `Function Expression`

| Syntax | ```html functionExpression() ``` |
| Description | Editor for Jsonnet expressions, designed for medium or advanced operations, specifically for expression-type operations. |
| Input parameter | Not applicable (N/A) |
| Return type | N/A |
| Output | Provides an editor interface for creating advanced Jsonnet expressions. |
|---|---|

*** ** * ** ***

### `Is Null`

| Syntax | ```html isNull(value) ``` |
| Description | Checks if the given value is null and returns a boolean indicating the result. |
| Input parameter | **value:** The input value of any data type to be checked for null. |
| Return type | `BOOLEAN` |
| Output | Returns `true` if the value is null; otherwise, returns `false`. |
|---|---|

## Recommendation

- Learn how to add and configure a [Data Transformer Script task](https://docs.cloud.google.com/application-integration/docs/configure-data-transformer-script-task.md.txt)