diff --git a/test/test.smartobject.ts b/test/test.smartobject.ts index 691a059..8df9e7a 100644 --- a/test/test.smartobject.ts +++ b/test/test.smartobject.ts @@ -10,6 +10,7 @@ tap.test('should create a smartobject', async () => { yeah: 'so deep', evendeeper: { sodeep: 2, + deepArray: ['one array', 'two array'] } } } diff --git a/ts/tools/toFlatObject.ts b/ts/tools/toFlatObject.ts index b026314..508bf18 100644 --- a/ts/tools/toFlatObject.ts +++ b/ts/tools/toFlatObject.ts @@ -4,7 +4,7 @@ export const toFlatObject = (objectArg: object) => { if (subObject) for (const key of Object.keys(subObject)) { let localPathArg = pathArg; - if (typeof subObject[ key ] === 'object') { + if (typeof subObject[ key ] === 'object' && !(subObject[ key ] instanceof Array)) { const newLoopbackArray = loopProtection.slice(); newLoopbackArray.push(subObject); extractLayer(subObject[ key ], localPathArg ? localPathArg += `.${key}` : key, newLoopbackArray);