How to: Turn Object Keys Into camelCase Using Lodash

Overview

Sometimes, you might need to change your data objects to camelCase A naming convention for computer programming. Use camelCase for Property IDs, for example: newUser, lastName, & rdoButton.. This is especially helpful when building your applications since Unqork uses camelCase for object and Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. naming. To do that, use the _.invert and _.camelCase Lodash functions.

TIP  To read more about the _.invert and _.camelCase parameters, you can visit: https://lodash.com/docs/4.17.15.

How This Example Works

To turn your data into camelCase, you must first retrieve a data set with object keys that do not use camelCase. In this example, you'll retrieve your data from a transform. Once you have the data in your module, your Data Workflow swaps the information in your object's key and value pairs. Then, your Data Workflow turns your inverted object values into camelCase. The last step inverts the key/value pairs again to their original order.

Here are the basic steps for this example: 

1. Set up and execute the transform's input data.
2. Invert input data keys into object values.
3. Convert inverted values into camelCase.
4. Revert inverted values into object keys.

Here's how the completed configuration looks in the Module Builder:

A static image displaying the turn object keys into camelCase using Lodash use case in the UDesigner module builder.

 

Resources