Git Product home page Git Product logo

jsontojava's Introduction

Json2Java

I was fed up with writing Java classes to mirror json models. So I wrote this Java app to automate the process.

What this tool can do right now:

Give it:
  • a url to a json file
  • a package name for the classes it will generate
  • the name of the base class to start with.
  • optionally, the p option will make your classes parcelable.
  • optionally, the g option will give your classes gson annotations for serialization.

It will create the folder structure for the package you provide, then it will read the json at the url you provide, and output java classes into a zip file.

The easiest way to actuall use this is to go to http://jsontojava.appspot.com/
There you can just put in the variables and click download.

When run from the commandline, it looks like this:

java -jar JsonToJava.jar -url http://example.com/folder.json -package com.example.api.model -class Folder -p -g

Each class will implement Parcelable for easy passing of information in Android (optional). Each class will have a default empty constructor. The members of each class will follow Android naming conventions with an "m" prefix and camel case. Each member will have a corresponding static final String that relates it to it's json counterpart Each member will have a @SerializedName annotation for very easy Gson parsing. (optional) If a member called "mId" or "mUniqueId" is found, then equals and hashcode will be overridden so comparisons are made on the id.

What I want this tool to do in the future in no particular order

  • Work as an App Engine app
  • Accept either a url or a block of json pasted in a text box
  • Extract superclasses
  • Accept multiple urls to build up the whole model
  • Allow the user to choose between Gson annotations, Jackson annotations, org.json constructors and toJson() methods, or none of the above
  • Give users the ability to rename classes
  • Give users the ability to ignore classes

jsontojava's People

Contributors

jonfhancock avatar npike avatar

Watchers

william avatar 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.