Work with objects of different cased keys
JavaScript HTML Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
History.md
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

obj-case

Work with objects of different cased keys. Anything supported by nbubna/Case. Makes finding and editing objects between languages a little more forgiving while still not modifying the original JSON.

Build Status

Installation

Install with component(1):

$ component install segmentio/obj-case

API

.find(obj, key)

Returns the value for the object with the given key

var obj = { my : { super_cool : { climbingShoes : 'x' }}};
objCase.find(obj, 'my.superCool.CLIMBING SHOES');  // 'x'

.del(obj, key, val, [options])

Deletes a nested key

var obj = { 'a wild' : { mouse : { APPEARED : true }}};
objCase.del(obj, 'aWild.mouse.appeared');
console.log(obj); // { 'a wild' : { mouse : {} }}

.replace(obj, key, val, [options])

Replaces a nested key's value

var obj = { replacing : { keys : 'is the best' }};
objCase.replace(obj, 'replacing.keys', 'is just okay');
console.log(obj) // { replacing : { keys : 'is just okay' }}

License

MIT