Thursday, October 18, 2012

How to generate Java Class files from JSON

A simple online tool which can generate Java Classes from the JSON data directly. There are little bugs in the tool. For example if the JSON data contains a space, the generator will create a variable name with space. But as per Java, you cannot have space in between variables. Other than this I found the tool good enough to generate Java classes from JSON data.

Sample JSON Data

I have written a sample JSON to test this tool. You can get the JSON from PasteBin or try this tool with your own JSON data. You can visualize the structure of your JSON using several online JSON converters. I have used JSONViewer from Stack.hu. Below is the structure of my sample JSON data.



Generating Java Class from JSON


You can use JSON Gen – Client Code generation tool from ByintonDesign.com to generate Java classes from JSON data. The best part is the you could specify your JSON Data Class name and the Package name while generating.

One small drawback is the site doesn’t have option to directly paste the JSON data. You got to specify the url containing the JSON data, one quick workaround is to use online clipboards such as PasteBin to generate URL for the data. Click on the Raw option as shown below in the paste to get the direct url.

Your Comments

0 Responses to "How to generate Java Class files from JSON"