json-style-converter
A tiny utility module for converting json objects between various coding styles. This is especially useful in projects which are written in multiple programming languages and use REST Apis
to comunicate - for example backend in Ruby
, frontend in JavaScript
.
Install via npm
npm i json-style-converter
Example usage
const converter = ; converter; /* returns{ snakeCase: "A simple test", camelCase: 42, array: [ { itWorks: true }, { itWorks: null } ]}*/
For using the es5 browser compatible Build
const converter = ;
or
;
API
converter.snakeToCamelCase
Transforms all the keys of object recursively from snake_case
to camelCase
.
converter.camelToSnakeCase
Transforms all the keys of object recursively from camelCase
to snake_case
.
-- Ping me on twitter, i'd be more than happy to hear your thoughts!
Alex M