https://github.com/busterc/casing
:wrench: Recursively transform object key strings to and from camelCase and snake_case
https://github.com/busterc/casing
camelcase json-serialization snake-case
Last synced: about 1 year ago
JSON representation
:wrench: Recursively transform object key strings to and from camelCase and snake_case
- Host: GitHub
- URL: https://github.com/busterc/casing
- Owner: busterc
- Created: 2014-11-07T17:13:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-01-24T20:23:59.000Z (over 7 years ago)
- Last Synced: 2024-04-15T08:08:41.092Z (about 2 years ago)
- Topics: camelcase, json-serialization, snake-case
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# casing
> Recursively transform object key strings to and from camelCase and snake_case.
- Supports objects, arrays and a combination of both in any depth.
- Was originally intended for use with BookShelf and Knex.
## Installation
```sh
$ npm install casing
```
## Usage
```javascript
'use strict';
var casing = require('casing');
var wasCamel = {
objId: 123,
myName: 'Slim Shady'
};
console.log(casing.snakeize(wasCamel));
// => { obj_id: 123, my_name: 'Slim Shady' }
var was_snake = {
obj_id: 456,
my_name: 'fiddycent'
};
console.log(casing.camelize(was_snake));
// => { objId: 456, myName: 'fiddycent' }
```
### TypeScript
This package includes a definition file for TypeScript.
```ts
import { camelize, snakeize } from 'casing';
var wasCamel = { objId: 123 };
snakeize(wasCamel);
var was_snake = { obj_id: 456 };
camelize(was_snake);
```
## License
MIT