normalize objects using various types of casing
npm install normalize-object
Based off of normalize-case
npm install normalize-object
Normalize an object and all of its keys (included nested object keys and objects in arrays)
to the format of your choosing.
normalize(obj, caseType)
Where caseType defaults to camel case
Supports the following casing types:
* camel
* capital
* constant
* lower
* pascal
* sentence
* snake
* title
* upper
``javascript
var normalize = require('normalize-object');
var input = {
api_key: "baz",
"first name": "baz",
last_name: "foo",
array: [
{ Name: "baz" },
{ "names ": [A: 1] }
]
};
var output = normalize(input, 'camel'); // camel is used by default
`
Where output would be:
`javascript``
var output = {
apiKey: "baz",
firstName: "baz",
lastName: "foo",
array: [
{ name: "baz" },
{ names: [a: 1] }
]
};
npm test