json-style-converter
v1.0.3
Published
A tiny utility module for converting json objects between various coding styles
Downloads
537
Maintainers
Readme
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 = require( "json-style-converter" );
converter.snakeToCamelCase( {
snake_case: "A simple test",
camelCase: 42,
array: [ {
it_works: true
}, {
it_works: null
} ]
} );
/* returns
{
snakeCase: "A simple test",
camelCase: 42,
array: [ {
itWorks: true
}, {
itWorks: null
} ]
}*/
For using the es5 browser compatible Build
const converter = require( "json-style-converter/es5" );
or
import converter from "json-style-converter/es5";
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