LoginSignup
0
0

More than 3 years have passed since last update.

[Android/Kotlin] Android Studioで JSON Kotlin Class 簡単に作ってみた。

Posted at

JSONデータをKotlin classに変更するため
json to kotlin classというプラグインをインストールする。

Android Studioのpluginsで
json to kotlin class を打つと下記のようにプラグインが出ます。

スクリーンショット 2021-02-28 17.13.43.png

インストールるしてIDEを再実行する。

スクリーンショット 2021-02-28 17.19.13.png

new -> Kotlin data class File from JSON 又は

JSON データをコピーして Command + N を打つと

スクリーンショット 2021-02-28 17.20.25.png

上記のように出ます。

Kotlin data classes from JSONを押下した場合は

スクリーンショット 2021-02-28 17.38.39.png

JSON形式を書ける画面とグラス名を書ける画面がです。

入力して Generateを押下すると入力したJSON値を用いて下記のようにデータクラスを生成してくれる。

スクリーンショット 2021-02-28 17.39.32.png
スクリーンショット 2021-02-28 17.39.36.png

API通信などで Jsonをクラスを簡単に作って活用してみましょう!

0
0
0

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