Wednesday, 8 April 2015

Cool tool of the day: jsonschema2pojo

So we all love JSON?

AND I love Java but creating the Java classes to serve or parse your JSON is a pain.

Especially when the JSON alters!

So use jsonschema2pojo!

It comes with a handy code generator Maven plugin.

The steps are as follows:

  1. Create a Java project with a maven POM;
  2. Add the code generator as seen in the documentation;
  3. Capture your JSON;
  4. Create the JSON schema in the folder specified in your POM using jsonschema.net;
  5. run mvn generate-sources;
Done!