Images
Let’s format our API responses.
In many situations we will want to modify the value that comes back from a response in our API.
This is what Judo "helpers" are used for.
We can format dateTime objects, percentages, currencies and more.
Remember to download the Judo file in the Resources section at the top of this page, where you can see all supported helpers mentioned below in action.
List of all helpers currently available in Judo:
- lowercase & uppercase
- dateFormat
- replace
- numberFormat
- prefix
- suffix
- dropFirst
- dropLast
How To Use Helpers
You use helpers in any test field that is interpolating values from a Data Source.
You type the name of your helper inside your curly braces, before the value you are interpolating.

1) lowercase & uppercase
The first two are pretty straightforward. They allow you to take a string value and transform it to be either all lowercase or all uppercase, like so:

2) dateFormat
A very common use of a helper is to format dates and times.
Often date and time values show in our responses in a format that follows the ISO 8601 standard, represented by a single dateTime value, such as 2022-06-28T14:30:00+0000
A helper is used here to format this to display perhaps June 28, 2022, or 2:30pm, or any other common combo.
We can then tell our helper what format to use by placing the instruction code in quotations after our Data Source key, such as:

Here's some of the most common instruction codes:
- Tuesday, Jun 28, 2022 -> "EEEE, MMM d, yyyy"
- 06/28/2022 -> "MM/dd/yyyy"
- Jun 28, 8:28 PM -> "MMM d, h:mm a"
- June 28, 2022 -> "MMMM d, yyyy"
The full list of dateFormat instruction codes is available here:
3) replace
We can use a helper to replace certain areas of our value.
It can remove unwanted spaces, punctuation or entire words.
Perhaps we are working with our fictitious Fitness app experience that we've used earlier in the Learning Center. It contains a list of workout videos. But what if the title came back containing "Min" but we wanted it to say "Minutes" instead.
This is where the replace helper comes to the rescue.
Here's a screenshot of our Fitness app experience using the replace helper:

With the replace helper, there are 2 pieces of instructions:
• what we want to be replaced
• what we want to replace with

Multiple Replace Helpers
You might've been wondering if you can use multiple helpers on the same field...
the answer is yes! 🎉
Essentially you use a nested helper with normal brackets instead of curly brackets, all wrapped around your key like so:

.png)
4) numberFormat
While the helpers so far are used to format strings, the numberFormat helper is how we format numbers.
There are three variations of the numberFormat helper:
- percent
- currency
- decimal
percent will take a 0.xx number value and turn it into a percent.
currency will format the value into a currency value adding the appropriate currency symbol based on the users' device locale settings.
decimal will no longer round up to a whole integer but will display as the decimal value (rounded to 3 decimal points).
Here's a screenshot showing numberFormat in action:


5) prefix
This helper is used to limit strings to a certain amount of characters.
A common use-case would be to turn first names into first initials only.
Another use-case for this helper is to truncate long text to a certain number of characters.
Just like other helpers, this one takes an instructional value to tell the helper how many characters you'd like to limit:

.png)
6) suffix
This one is the opposite of prefix. It will only keep a certain number of characters, counting backwards from the end of the string.
Helpful for removing leading spaces or other unwanted characters at the beginning of your string.
So if you had a word such as Basketball, and you used the suffix helper with a value of 4, it would display only ball.

7) dropFirst
This one is similar to prefix, but instead of limiting your string from a certain number of characters counting from the beginning, it will remove a certain number of characters from the beginning of your string.

8) dropLast
This one is now similar to suffix, but instead of limiting your string from a certain number of characters counting from the end, it will remove a certain number of characters from the end of your string.

That’s it for Helpers.
Hopefully they help you customize and format the fields coming back from Data Source responses in your Judo experiences.
See you in the next lesson.