0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

javascriptのキャメールケース・スネークケース変換ライブラリ

Posted at

概要

BE側のAPIレスポンスはsnake_caseだが、FE側のJavaScript/TypeScriptはcamcelCaseが相応しい。それのあなを埋めるために通信部で自動的に変換したほうがらくである。

キャメールケース変換Library:camelcase-keys

選ぶ理由:軽量、サイズが小さい

Unpacked Size
12.9 kB
camelcaseKeys({'foo_bar': true});
//=> {fooBar: true}

スネークケースLibrary:decamelize-keys

選ぶ理由:軽量、サイズが小さい、camelcase-keysと同じ人の作品

Unpacked Size
8.5 kB
// Convert an array of objects
decamelizeKeys([{fooBar: true}, {barFoo: false}]);
//=> [{foo_bar: true}, {bar_foo: false}]
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?