Webanizr Logo
Open / sluit menu
Module transformData

Last change: October 7, 2019

Current version: 1.5.2

The transformData module transforms the given data before passing it on to the next module.

syntax

webanizr.send('transformData', data, parameters, callback);

data

The data that has to be transformmed before passing it on.

parameters

transformData accepts the following parameters:

startpoint__structure (optional)

By default the transformData only manipulates keys and values on the highest level. If you want to manipulate the keys and values of a specific sublist you can specify the key name of this sublist in this parameter. If you want to apply the transformation on all sublists (one level deep) you can set this parameter to '*'.

filter__data (optional)

A filter function to select certain elements to perform the transformation on. You can use a formula where you can use the key and/or value for comparisson. If you only want key "mykey" you can use the following value for this parameter: '{key__element}' == 'mykey'. If you only want elements with a value greather than 5 you can use '{value__element} > 5.

prependstring__keys (optional)

Prepends a string to all keys.

appendstring__keys (optional)

Appends a string to all keys.

replacein__keys (optional)

Replaces text in all keys. Supply an array with two elements: the first element is the text to replace, the second one the text to replace it with.

prependstring__values (optional)

Prepends a string to all values.

appendstring__values (optional)

Appends a sting to all vallues.

translate__values (optional)

Translates the vaues. The collect of the translate module has to be called before.

onlyvalues__structure (optional)

Turns a Object into an array by removing all keys. This parameter applies directly to the top level and does nog follw the startpoint__structure parameter.

useforkeys__values (optional)

If set to true, the values of the given data will also be used as keys. If double values are merged to one single records.

callback

The callback function that receives the transformed data.

demo

https://cdn.cpmodules.webanizr.com/demo/transform-data/index.html

changelog

  • October 7, 2019, 1.5.2 - support for multiple occurences of {key__element} and {value__element} in filters
  • October 6, 2019: 1.5.1 - added the option for translate values