$ gnpm install decamelize-keys
Convert object keys from camel case using
decamelize
npm install decamelize-keys
import decamelizeKeys from 'decamelize-keys';
// Convert an object
decamelizeKeys({fooBar: true});
//=> {foo_bar: true}
// Convert an array of objects
decamelizeKeys([{fooBar: true}, {barFoo: false}]);
//=> [{foo_bar: true}, {bar_foo: false}]
Type: object | object[]
An object or array of objects to decamelize.
Type: object
Type: string
Default: '_'
The character or string used to separate words.
import decamelizeKeys from 'decamelize-keys';
decamelizeKeys({fooBar: true});
//=> {foo_bar: true}
decamelizeKeys({fooBar: true}, {separator: '-'});
//=> {'foo-bar': true}
Type: Array<string | RegExp>
Default: []
Exclude keys from being decamelized.
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
import decamelizeKeys from 'decamelize-keys';
decamelizeKeys({fooBar: true, nested: {unicornRainbow: true}}, {deep: true});
//=> {foo_bar: true, nested: {unicorn_rainbow: true}}
Copyright 2013 - present © cnpmjs.org | Home |