JsonToKotlinClass

简介:A plugin for Kotlin to convert Json String into Kotlin data class code
能将 Json 数据直接映射生成 Kotlin Data Class 代码,免去手动编写数据对象结构声明
更多:作者   提 Bug   
标签:
kotlin-json-plugin-data class-

Hi,Welcome to come to see me! I am a plugin for Kotlin generate Kotlin data class code from a json string

I am a plugin for Kotlin to convert Json String into Kotlin data class code (Json to Kotlin)

Update Log

1.2

  • Add support for generate anotations for target json lib --gson
  • Add Comment option to switch the comment content to append

1.1

  • Add property keyword config setting like ('var' or 'val'),the default keyword changed to 'val'.

How to use

  • Search 'JsonToKotlin' in Intellij Idea Plugin Repositroy Or AndroidStudio Repository And Install it.
  • Restart your Develop tools
  • Press short key ALT + K And Then you will know how to use

Default:

alt text

Config with gson support on

alt text

Generate Example

  • example with none json lib support and comment option on

          data class FD(
                  val programmers: List<Programmer>,
                  val authors: List<Author>,
                  val musicians: List<Musician>
          )
    
          data class Musician(
                  val firstName: String, //Eric
                  val lastName: String, //Clapton
                  val instrument: String //guitar
          )
    
          data class Author(
                  val firstName: String, //Isaac
                  val lastName: String, //Asimov
                  val genre: String //science fiction
          )
    
          data class Programmer(
                  val firstName: String, //Brett
                  val lastName: String, //McLaughlin
                  val email: String //aaaa
          )
    
  • example with gson option on

          data class FD(
                  @SerializedName("214123addre++/-*ssbook") val addressbook: List<addressbook>
          )
    
          data class addressbook(
                  @SerializedName("*-/-+address") val address: address,
                  @SerializedName("name") val name: String, //Ann Michaels
                  @SerializedName("phoneNumbers") val phoneNumbers: List<String>
          )
    
          data class address(
                  @SerializedName("city") val city: List<String>,
                  @SerializedName("*-/32432-*/4street") val street: List<String>,
                  @SerializedName("zip") val zip: List<Int>
          )
    

More Detail Document

Others

  • Welcome anyone to raise new issue.
  • Welcome anyone to push a pull request to improve me.

Find me useful ? :heart:

  • Support me by clicking the :star: button on the upper right of this page. :v:
Android 开发经验分享
C 轮融资近 30 亿元理财推荐
Android 开发经验分享
C 轮融资近 30 亿元理财推荐