Skip to content
Advertisement

jsonschema and date type

I’m just getting started with jsonschema and an example under “Using jsonschema2pojo within your Java project (embedded)” in https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started

having in mind data types of jsonschema listed here https://developers.google.com/discovery/v1/type-format?hl=en

my schema object can be described as

JavaScript

unfortunately a generated Pojo object will be

JavaScript

has a member “displayDate” of a type Object instead of expected Date. Why?

Advertisement

Answer

date is not a valid value for type. displayDate should be defined as

JavaScript

I don’t know if jsonschema2pojo will convert that to a Date object like you want, but it seems that it is defaulting to Object instead of throwing an error when it encounters the invalid value for type.

Advertisement