Fix parsing nested array with non-objects when updating
This commit is contained in:
parent
231b51445a
commit
5009308c52
1 changed files with 12 additions and 0 deletions
|
@ -7,6 +7,12 @@ import {snakeCase} from 'snake-case'
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function objectToCamelCase(object) {
|
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 = {}
|
let parsedObject = {}
|
||||||
for (const m in object) {
|
for (const m in object) {
|
||||||
parsedObject[camelCase(m)] = object[m]
|
parsedObject[camelCase(m)] = object[m]
|
||||||
|
@ -38,6 +44,12 @@ export function objectToCamelCase(object) {
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function objectToSnakeCase(object) {
|
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 = {}
|
let parsedObject = {}
|
||||||
for (const m in object) {
|
for (const m in object) {
|
||||||
parsedObject[snakeCase(m)] = object[m]
|
parsedObject[snakeCase(m)] = object[m]
|
||||||
|
|
Loading…
Reference in a new issue