0

I am currently Generating Pojo class using JsonSchema2Pojo, My json schema has couple of class related to Date of birth, Start Date and End date which is defined with type number, when i generate the Pojo class, its of type Double and I am unable to pass int value,

E.g if I am trying to set date of birth as 1/1/2020, it says Required Double and Passed int.

I have tried to use true which has not worked, also I don't find any supporting tags to convert number to int in jsonschema2pojo properties

enter image description here

Nimantha
  • 6,405
  • 6
  • 28
  • 69

2 Answers2

0

It looks like you need to manually change the type of those variables.

In general there is a bit discrepancy in the types between Java and Javascript. Javascript has only "number" for both int and float values. Where Java has separate types.

I believe the generator uses Double since it is technically more correct but in you context you should go ahead and change the types to int or Integer manually.

Deian
  • 1,237
  • 15
  • 31
0

If you can edit these field types to "integer" instead of "number" in your schema and use JsonSchema2Pojo then it will generate them as integer.

Alternatively, you could edit them manually if you don't want to change schema.