# JSON encode transform function

## Introduction

The **JSON encode** transform function is encode incoming values as JSON. For example, you might have product data in a string:

{% code lineNumbers="true" %}

```json
{"last_fruit":"apples"}
```

{% endcode %}

...and need to encode the values for pushing to the destination system:

{% code lineNumbers="true" %}

```json
{"last_fruit":"\"apples\""}
```

{% endcode %}

{% hint style="info" %}
Although this is listed as a string type transform, in fact any data type can be encoded.
{% endhint %}

## Adding a last word transform

**Step 1**\
In your process flow, access settings for your map shape:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FU09ztECjyLK9gwyqm7PB%2Fadd%20last%20word%20transform%201.png?alt=media&#x26;token=34e0472a-ad7e-455b-b908-61e433ad38ea" alt="" width="285"><figcaption></figcaption></figure></div>

**Step 2**\
Select the **add transform** icon for the required mapping rule - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FNuV8NyUk38XgqElMzQ6n%2Fadd%20last%20word%20transform%202.png?alt=media&#x26;token=7aeea75d-21e8-48d8-aa1a-5783d83ccba3" alt=""><figcaption></figcaption></figure></div>

**Step 3**\
Click the **add transform** button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FcfuSmh29BRxphU6DAvdY%2Fadd%20last%20word%20transform%203.png?alt=media&#x26;token=c4341b4e-adc7-4782-961b-b84058f9cd3a" alt=""><figcaption></figcaption></figure></div>

**Step 4**\
Click in the **name** field to access a list of all available transform functions, then select **JSON encode** from the **string** category:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fyqh21EYzOVxxysU0kHfV%2Fjson%20encode%201.png?alt=media&#x26;token=1b12be39-1753-43d2-821e-e56d2a63f15b" alt=""><figcaption></figcaption></figure></div>

**Step 5**\
Click the **add field** button:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FcaDmFvWZZ1I05y1hvL88%2Fjson%20encode%202.png?alt=media&#x26;token=dab3596b-ecad-4983-97c5-620df9487db5" alt=""><figcaption></figcaption></figure></div>

**Step 6**\
Click in **source fields** and select the source field to be used for this transform:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fp95KbfNP598wSn9xEdaU%2Fjson%20encode%203.png?alt=media&#x26;token=0011ff18-6b7d-4631-8c62-63f663e64ce1" alt=""><figcaption></figcaption></figure></div>

**Step 7**\
Accept your changes:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F3ySx4p2L348FxOn9kxtX%2Fadd%20last%20word%20transform%208.png?alt=media&#x26;token=01ac5a00-b05c-4928-974e-6c5f337f9727" alt=""><figcaption></figcaption></figure></div>

**Step 8**\
Save the transform. You'll notice that the transform icon is updated to indicate that a transform function is present for the mapping row - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F9JuI5rl5CYY3HsdYHJ0q%2Fadd%20last%20word%20transform%209.png?alt=media&#x26;token=1ca96575-c365-4a55-acb1-0f4fde93d592" alt=""><figcaption></figcaption></figure></div>
