# jsontojava
**Repository Path**: 506/jsontojava
## Basic Information
- **Project Name**: jsontojava
- **Description**: java
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2015-02-13
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
本人用于Android开发的数据解析时用到
使用说明:
找到Main.java
private static final String OPTION_PACKAGE = "com.qnvip.ypk.model";
private static final String OPTION_URL = "http://api.qncentury.com/companyShop/index?adr=1&lng=0&lat=0";
private static final String OPTION_ROOT = "ShopDetail";
填写OPTION_PACKAGE包名
填写OPTION_URLjson数据来源
填写OPTION_ROOT实体类名称
运行即可
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.
- optionally, the s option will override the toString method.
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
- 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