Skip to content

jsonschema and date type

I’m just getting started with jsonschema and an example under “Using jsonschema2pojo within your Java project (embedded)” in

having in mind data types of jsonschema listed here

my schema object can be described as

    "$schema": "",
    "description": "Document",
    "type": "object",

    "properties": {
        "displayDate": { "type": "date" },
        "displayName": { "type": "string" }

unfortunately a generated Pojo object will be

package com.example;

public interface Document {

   java.lang.Object getDisplayDate();

   void setDisplayDate(java.lang.Object arg0);

   java.lang.String getDisplayName();

   void setDisplayName(java.lang.String arg0);


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



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

{ "type": "string", "format": "date" }

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.

6 People found this is helpful