Function: convertObject(obj, options = {})
Converts or extracts data from an object according to specified rules.
Parameters:
obj– The object to transform.options– Optional settings:
| Option | Type | Default | Description | ||
|---|---|---|---|---|---|
outputFormat |
`'flat' | 'tree' | 'nestedKeys'` | 'flat' |
Output structure format. |
props |
string | string[] | RegExp |
null |
Filter keys to include. | ||
filterFn |
(val, key, path) => boolean |
null |
Custom filter function. | ||
mapFn |
(val, key, path) => any |
(v) => v |
Transform values. | ||
includeKeys |
boolean |
false |
If true, flat output returns [key, value]. |
||
includePaths |
boolean |
false |
Use full path as key in flat output. | ||
flatten |
boolean |
true |
Traverse nested objects. | ||
defaultValue |
any |
undefined |
Fallback value for missing entries. | ||
strict |
boolean |
false |
Throw error if key/value not found. | ||
maxDepth |
number |
Infinity |
Limit traversal depth. | ||
sort |
boolean |
false |
Sort keys alphabetically. | ||
prefix |
string |
'' |
Start traversal at nested path. | ||
keyKey |
string |
'key' |
Key name in tree nodes. | ||
valueKey |
string |
'value' |
Value name in tree nodes. | ||
childrenKey |
string |
'children' |
Child array key for tree output. |