convert-keys
v1.3.4
Published
Convert object keys to camelCase or snakeCase.
Downloads
13,282
Maintainers
Readme
convert-keys
Install
$ npm install convert-keys
Usage
const convertKeys = require('convert-keys');
const obj = {
'hoge_fuga': 1,
hogeHoge: {
'piyo_piyo': 'aaaa',
'fuga_fuga': 'bbbb'
}
};
convertKeys.toCamel(obj);
// output
{
hogeFuga: 1,
hogeHoge: {
piyoPiyo: 'aaaa',
fugaFuga: 'bbbb'
}
}
convertKeys.toSnake(obj);
// output
{
'hoge_fuga': 1,
'hoge_hoge': {
'piyo_piyo': 'aaaa',
'fuga_fuga': 'bbbb'
}
}