jonfhancock / jsontojava Goto Github PK
View Code? Open in Web Editor NEWI was fed up with writing Java classes to mirror json models. So I wrote this Java app to automate the process.
License: Apache License 2.0
I was fed up with writing Java classes to mirror json models. So I wrote this Java app to automate the process.
License: Apache License 2.0
1>
{
"responseCode": "200",
"responseMessage": "OK"
}
private String mResponseMessage this should be responseCode. when we use GSON parsing it's really helpful.
2>
I also observed if the Json object prefix is { "Options" :{.....}} the class name changes from Options to Option.java !! it should be Options.java
3>
"doc_value": "a2" after code generation changes to String mDocValue; this is not good! we have to rename it again or we have to use @SerializedName("3") annotations!
{"liveInfo":[{"id":"info","des":"","audio":"http://live.3gv.hehe.com/101","bkgURL":"http://y0.heheimg.com/a/2014_10/e08b6b07cb74d3f.jpg","channelId":"4AC51C17-9FBE-47F2-8EE0-8285A66EAFF5","unVideo":"http://live.cuff.hehe.com/zixun.m3u8","name":"hehe","smallIconURL":"http://y1.heheimg.com/a/2014_10/ccddb083e872c7b.png","unAudio":"http://live.cuff.hehe.com/101","bigIconURL":"http://y3.heheimg.com/a/2014_10/3ceafc4fb3b0b00.png","video":"http://live.3gv.hehe.com/zixun.m3u8"},{"id":"chinese","des":"","audio":"http://live.3gv.hehe.com/102","bkgURL":"http://y2.heheimg.com/a/2014_10/4a5c63674d61418.jpg","channelId":"270DE943-3CDF-45E1-8445-9403F93E80C4","unVideo":"http://live.cuff.hehe.com/zhongwen.m3u8","name":"hehehuhu","smallIconURL":"http://y1.heheimg.com/a/2014_10/1ee94d0bfb238a9.png","unAudio":"http://live.cuff.hehe.com/102","bigIconURL":"http://y1.heheimg.com/a/2014_10/38cf06f306393ef.png","video":"http://live.3gv.hehe.com/zhongwen.m3u8"},{"id":"hongkong","des":"","audio":"http://live.3gv.hehe.com/103","bkgURL":"http://y3.heheimg.com/a/2014_10/1e65a127e23bc1a.jpg","channelId":"2c942450-2165-4750-80de-7dff9c224153","unVideo":"http://live.cuff.hehe.com/hongkong.m3u8","name":"hehexxxx","smallIconURL":"http://y3.heheimg.com/a/2014_10/477fb893c64278d.png","unAudio":"http://live.cuff.hehe.com/103","bigIconURL":"http://y3.heheimg.com/a/2014_10/0b7ae487eb72af1.png","video":"http://live.3gv.hehe.com/hongkong.m3u8"},{"id":"cctv13","des":"","audio":"http://live.3gv.hehe.com/161","bkgURL":"http://y0.heheimg.com/a/2014_10/58296d58098f3a4.jpg","channelId":"5435BFA3-210B-4F4F-A90F-BCB1C4C40D59","unVideo":"http://live.cuff.hehe.com/cctv13.m3u8","name":"CCTV13","smallIconURL":"http://y3.heheimg.com/a/2014_10/0cd0c207cf2dc10.png","unAudio":"http://live.cuff.hehe.com/161","bigIconURL":"http://y3.heheimg.com/a/2014_10/bec87305e93dba6.png","video":"http://live.3gv.hehe.com/cctv13.m3u8"},{"id":"ahws","des":"","audio":"http://live.3gv.hehe.com/165","bkgURL":"http://y0.heheimg.com/a/2014_10/7b8ff78bfc711d0.jpg","channelId":"8550DAD6-8724-4474-8A95-F30967CAA294","unVideo":"http://live.cuff.hehe.com/ZJWS.m3u8","name":"fdsfsfd","smallIconURL":"http://y1.heheimg.com/a/2014_10/177e597345de785.png","unAudio":"http://live.cuff.hehe.com/165","bigIconURL":"http://y0.heheimg.com/a/2014_10/a2bf9373fdb4a43.png","video":"http://live.3gv.hehe.com/ZJWS.m3u8"},{"id":"tjws","des":"","audio":"http://live.3gv.hehe.com/166","bkgURL":"http://y2.heheimg.com/a/2014_10/8b8965f5c5ebcfc.jpg","channelId":"35383695-26c3-4ce5-b535-0001abce11e4","unVideo":"http://live.cuff.hehe.com/CQWS.m3u8","name":"sdfsdfs","smallIconURL":"http://y3.heheimg.com/a/2014_10/54d1e174ec8d781.png","unAudio":"http://live.cuff.hehe.com/166","bigIconURL":"http://y1.heheimg.com/a/2014_10/f55c789dc554969.png","video":"http://live.3gv.hehe.com/CQWS.m3u8"},{"id":"szws","des":"","audio":"http://live.3gv.hehe.com/167","bkgURL":"http://y3.heheimg.com/a/2014_10/3c1a861ac668f1a.jpg","channelId":"3072FC61-4763-4BE9-AA19-2B241498775A","unVideo":"http://live.cuff.hehe.com/SZWS.m3u8","name":"sdfsfsf","smallIconURL":"http://y0.heheimg.com/a/2014_10/f2aa7a7b8cabf36.png","unAudio":"http://live.cuff.hehe.com/167","bigIconURL":"http://y0.heheimg.com/a/2014_10/eb2b80875e98698.png","video":"http://live.3gv.hehe.com/SZWS.m3u8"}]}
Created PublicIpAddress.java
Created InnerIpAddress.java
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NullPointerException
at com.jsontojava.Member.getGetterSignature(Member.java:104)
at com.jsontojava.Member.getGetter(Member.java:125)
at com.jsontojava.NewType.toString(NewType.java:128)
at com.jsontojava.Main.main(Main.java:90)
It would be helpful if you could also generate the toString()
method for each model class. It should output the values for each member variable. Here is an example:
@Override
public String toString() {
return "deg = " + mDeg + ", gust = " + mGust + ", speed = " + mSpeed;
}
In the UI you can add an option to let the user decide whether the method should be generated.
Cannot run in tomcat, when click download button, prompts 404
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.