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
.
npm i json-style-converter
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";
Transforms all the keys of object recursively from snake_case
to camelCase
.
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