Object to Array
Description
Section titled “Description”This module converts a JavaScript object into an array using various configurable conversion modes. It supports six different modes: values (values only), keys (keys only), entries (key-value objects), entriesArray ([key, value] arrays), indexed (indexed objects with position), and numbered (sorting by numeric keys). It can optionally preserve the original object along with the converted result. It can also allow direct pass-through of data that is already arrays. It is essential for adapting data formats between modules that expect arrays and modules that produce objects.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| conversionMode | string | No | Conversion mode: values, keys, entries, entriesArray, indexed, numbered. Default values. |
| keyName | string | No | Property name for the key in entries and indexed modes. Default key. |
| valueName | string | No | Property name for the value in entries and indexed modes. Default value. |
| preserveOriginal | boolean | No | If true, includes the original object along with the converted array. Default false. |
| allowArrayPass | boolean | No | If true, allows arrays to pass through unmodified. If false and the input is an array, returns an error. Default false. |
Output
Section titled “Output”{ "nextModule": "siguiente_modulo", "data": [ { "key": "nombre", "value": "Juan" }, { "key": "edad", "value": 30 } ], "_meta_": { "originalType": "object", "conversionMode": "entries", "originalKeysCount": 2, "resultingLength": 2, "description": "Convertido a array de objetos con propiedades 'key' y 'value'" }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”{ "conversionMode": "entries", "keyName": "campo", "valueName": "valor", "preserveOriginal": false, "allowArrayPass": true}valuesmode: returnsObject.values(data)— values onlykeysmode: returnsObject.keys(data)— keys onlyentriesmode: returns objects with customizable properties for key and valueentriesArraymode: returns[key, value]arrays (Object.entries format)indexedmode: likeentriesbut adds anindexfield with the positionnumberedmode: sorts keys numerically and returns values in that order (for numeric keys only)- If
preserveOriginalistrue, the output is{ converted: [...], original: {...}, _meta_: {...} } - The
_meta_includes detailed information about the conversion performed
Related Nodes
Section titled “Related Nodes”- objectArrayConverter (bidirectional object/array conversion)
- iterador (iterate over the resulting array)
- mapFunction (transform each array element)