0

Familiar with Java and XML, I have tried to process JSON data. I'm using jsonschema2pojo to generate Plain Old Java Objects from example JSON data.

Let's say I want to import products and categories from a webshop;

http://developers.seoshop.com/api/resources/product http://developers.seoshop.com/api/resources/category

jsonschema2pojo does its job, but what about all generated Resource, Resource_, Resource__, Resource____ etc. files?

enter image description here

All these Resource classes are equal. Can I just delete these (and replace them bij one Resource class)? What is the reason for all these duplicated classes?

(don't mind the .json and .schema.json file they're just for investigation)

Arghavan
  • 1,125
  • 1
  • 11
  • 17
Roland Beuker
  • 354
  • 1
  • 15

1 Answers1

0

If you have nested classes you can modify the ObjectRule.java and RuleFactory.java a bit. I created a Hash of Class Name, JSON node and the package using MD5 algorithm and stored it in a map. Before creating any new class I just check if it's hash already exists in the hashMap in which case I just return the class corresponding to that hash.

Check my commit here : mdfaizanali786/jsonschema2pojo@e5343db#diff-7fef584364765f2bd47a596ad18cecc4

If you have top level duplicate classes you can fetch the schema, jsonify it and then again do similar check that it is not identical.

some random guy
  • 430
  • 5
  • 9