← 全部文章

前后端数据转换工具 humps

humps.camelize('hello_world') // 'helloWorld' humps.decamelize('fooBar') // 'foo_bar' humps.decamelize('fooBarBaz', { separator: '-' }) // 'foo-bar-baz' var object = { attr_one: 'f…

在知乎阅读全文

humps.camelize('hello_world') // 'helloWorld' humps.decamelize('fooBar') // 'foo_bar' humps.decamelize('fooBarBaz', { separator: '-' }) // 'foo-bar-baz' var object = { attr_one: 'foo', attr_two: 'bar' } humps.camelizeKeys(object); // { attrOne: 'foo', attrTwo: 'bar' } var array = [{ attr_one: 'foo' }, { attr_one: 'bar' }] humps.camelizeKeys(array); // [{ attrOne: 'foo' }, { attrOne: 'bar' }]非常…