Coder Social home page Coder Social logo

mighty16 / jsontokotlinclass Goto Github PK

View Code? Open in Web Editor NEW
144.0 1.0 12.0 697 KB

Intellij Idea, Android Studio plugin for generating Kotlin data classes from JSON. Helps to avoid writing boilerplate code for model classes. Supports annotations for Gson, Moshi, Jackson.

Home Page: https://plugins.jetbrains.com/plugin/10054-generate-kotlin-data-classes-from-json

License: MIT License

Java 100.00%
android-studio-plugin json-to-kotlin intellij-plugin data-class

jsontokotlinclass's Issues

Support minimal Moshi json bindings

Differences

  1. keeps camel case json names
  2. needs some special case names e.g. .tag
  3. Doesn't default required vals like strings to "". Perhaps making more things nullable by default would help, as a single non-null result isn't proof it works.
// SharedLinkResponse
data class RevokeFailureReason(@Json(name=".tag") val tag: String)
data class TeamMemberInfo(val member_id: String, val team_info: TeamInfo, val display_name: String)
data class ResolvedVisibility(@Json(name=".tag") val tag: String)
data class TeamInfo(val name: String, val id: String)
data class LinkPermissions(val can_revoke: Boolean, val resolved_visibility: ResolvedVisibility, val revoke_failure_reason: RevokeFailureReason?)
data class SharedLinkResponse(val rev: String, val team_member_info: TeamMemberInfo?, val size: Int, val server_modified: String,
                              val path_lower: String, val name: String, val link_permissions: LinkPermissions,
                              @Json(name=".tag") val tag: String, val id: String, val client_modified: String, val url: String)

how to disable set default value ?

Hi, is there any way to disable set every field with default value(such as val someInt=0, val strField=""), maybe without it will be neater.

Numbers in JSON Are Removed In Target Name

If you have a json with numbers in keys like this:
"url16": "https://...", "url48": "https://..."

JSONToKotlinClass removed these numbers and the resulted class looked like this:
data class Icon(val url: String = "", val url: String = "",

This obviously results in a compiler error and you have to add the missing numbers manually.

react-native 空指针报错

Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable()' on a null object reference

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.