1

Jsonschema2pojo is behaving correctly. However I would like to change its behavior. After I run Jsonschema2pojo I end up with my top level classes (14 of them) and 14 member classes. The member classes look like "WatchSpecs.java", "WatchSpecs_.java", "WatchSpecs__.java", "WatchSpecs___.java", "WatchSpecs____.java", etc. So I end up with 14 classes that are exactly the same but have different names.

Is there a way to change this?

Thanks

p.s. I am NOT using ant or maven. Using Eclipse and including the jars.

// Versions
jsonschema2pojo-core-0.4.27
codemodel-2.4.1
jackson-annotations-2.6.3
jackson-core-2.6.3
jackson-databind-2.6.3
commons-lang-2.5
commons-lang3-3.4
GOOGGOOG
  • 11
  • 3

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 the check that it is not identical.

some random guy
  • 430
  • 5
  • 9