From 5009308c5266c51acfa00a2f50854702a008d7f7 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 30 Apr 2020 23:45:22 +0200 Subject: [PATCH] Fix parsing nested array with non-objects when updating --- src/helpers/case.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/helpers/case.js b/src/helpers/case.js index 6d01aafda..b0a9bc151 100644 --- a/src/helpers/case.js +++ b/src/helpers/case.js @@ -7,6 +7,12 @@ import {snakeCase} from 'snake-case' * @returns {*} */ export function objectToCamelCase(object) { + + // When calling recursively, this can be called without being and object or array in which case we just return the value + if (typeof object !== 'object') { + return object + } + let parsedObject = {} for (const m in object) { parsedObject[camelCase(m)] = object[m] @@ -38,6 +44,12 @@ export function objectToCamelCase(object) { * @returns {*} */ export function objectToSnakeCase(object) { + + // When calling recursively, this can be called without being and object or array in which case we just return the value + if (typeof object !== 'object') { + return object + } + let parsedObject = {} for (const m in object) { parsedObject[snakeCase(m)] = object[m]