Giter Site home page Giter Site logo

idhong / jsontokotlinclass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wuseal/jsontokotlinclass

0.0 1.0 0.0 218 KB

Plugin for Android Studio And IntelliJ Idea to generate Kotlin data class code from JSON text ( Json to Kotlin )

License: GNU General Public License v3.0

Kotlin 100.00%

jsontokotlinclass's Introduction

JsonToKotlinClass

GitHub release GitHub stars GitHub issues GitHub closed issues license

Kotlin IntelliJ Idea Plugin Android Studio Plugin

JsonToKotlinClass

Hi,Welcome to come to see me! I am a plugin for Kotlin generate Kotlin data class code from a JSON string also as say a plugin for Kotlin to convert JSON String into Kotlin data class code (Json to Kotlin)

Overview

Hi,This is a very cool tool for Kotlin developers ,It can convert the Json String into Kotlin Data Class code ,and paste it into your editor file ,The tool could recognize the Primitive Type of Json String and make Type Identifier respectively ,It taste easily ,Just have test,guys! Just press shortcut key ALT + K for Windows or Option + K for Mac,And then,start your Kotlin program travel ! JsonToKotlinClass make program more happy!

Functions

  • Generate Kotlin data class from any legal JSON text.
  • Support JSON Serialize Lib Annotation(Gson,Jackson,Fastjson,MoShi and LoganSquare)
  • Support customize your own Annotation
  • Support init property with default value
  • Support make property type to be nullable(?)
  • Support auto rename property name to be legal when select a target JSON lib.See demo

How to use

  • Search 'JsonToKotlinClass' in Intellij Idea Plugin Repositroy Or AndroidStudio Plugin Repository And Install it.
    File --> Settings --> Plugins --> Browse Repositories -->Search JsonToKotlinClass
  • Restart your Develop tools
  • Press shortcut key ALT + K for Windows or Option + K for Mac And Then you will know how to use

Demos

Default :

alt text

Configure with Gson support on and init with deault value on and comment off

alt text

Config with custome your own annotations support on and init with deault value 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 and init with default value option on

       data class TestData(
       		@SerializedName("ticketInfo") val ticketInfo: TicketInfo = TicketInfo(),
       		@SerializedName("trainInfo") val trainInfo: TrainInfo = TrainInfo(),
       		@SerializedName("trainScheduleHead") val trainScheduleHead: List<String> = listOf(),
       		@SerializedName("extInfo") val extInfo: ExtInfo = ExtInfo(),
       		@SerializedName("trainScheduleBody") val trainScheduleBody: List<TrainScheduleBody> = listOf()
       )
       
       data class TrainScheduleBody(
       		@SerializedName("mxl") val mxl: Long = 0, //12490639969101
       		@SerializedName("content") val content: List<Int> = listOf()
       )
       
       data class TrainInfo(
       		@SerializedName("T110") val t110: T110 = T110()
       )
     
    

Chinese Detail Document (中文文档)

Others

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

Thanks

  • Thank @davidbilik give me first awesome advice.
  • Thank @cgoodroe raise many awesome issues for me,Help me improve myself
  • Thank @wangzhenguang remains me the details of problem

Find me useful ? ❤️

  • Support me by clicking the ⭐ button on the upper right of this page. ✌️
  • Spread to others to let more people have a better develope expierience ❤️

jsontokotlinclass's People

Contributors

wuseal avatar sealkingking avatar mladenrakonjac avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.