https://github.com/hiroppy/convert-keys
Convert object keys to camelCase or snakeCase.
https://github.com/hiroppy/convert-keys
Last synced: 3 months ago
JSON representation
Convert object keys to camelCase or snakeCase.
- Host: GitHub
- URL: https://github.com/hiroppy/convert-keys
- Owner: hiroppy
- License: mit
- Created: 2016-11-22T16:30:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-09T09:59:27.000Z (over 5 years ago)
- Last Synced: 2025-04-11T17:16:47.821Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 159 KB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# convert-keys
[](https://travis-ci.org/hiroppy/convert-keys)
[](https://codecov.io/gh/hiroppy/convert-keys)
[](https://badge.fury.io/js/convert-keys)
# Install
```
$ npm install convert-keys
```
# Usage
```javascript
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'
}
}
```