Skip to content

MousaZeidBaker/snake_case_keys

Repository files navigation

snake-case-keys

Converts JSON keys to snake_case

Given the following JSON object:

[
  {
    "CamelCase": "I will be converted",
    "snake_case": "I am already snake case",
    "values": "areNotConverted",
    "nestedKeys": {
      "willBe": "converted as well"
    }
  }
]

will be converted to:

[
  {
    "camel_case": "I will be converted",
    "snake_case": "I am already snake case",
    "values": "areNotConverted",
    "nested_keys": {
      "will_be": "converted as well"
    }
  }
]

Getting started

  1. Install dependencies

yarn install

  1. Copy the src/object.example.json file and paste your JSON object to it

cp src/object.example.json src/object.json

  1. Compile TypeScript to JavaScript

yarn run build

  1. Convert to snake case

node dist/index.js

The output is JSON stringified, can be used together with jq to beautify the output

node dist/index.js | jq .

The output can be copied to the clipboard as follows

node dist/index.js | jq . | xclip -selection clipboard

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published