【发布时间】:2015-10-05 15:24:13
【问题描述】:
我刚刚开始使用 jsonschema 和下面的示例 “在 Java 项目中使用 jsonschema2pojo(嵌入式)” 在 https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started
记住此处列出的 jsonschema 的数据类型 https://developers.google.com/discovery/v1/type-format?hl=en
我的模式对象可以描述为
{
"$schema": "http://json-schema.org/draft-04/schema",
"description": "Document",
"type": "object",
"properties": {
"displayDate": { "type": "date" },
"displayName": { "type": "string" }
}
}
不幸的是,生成的 Pojo 对象将是
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);
}
有一个对象类型的成员“displayDate”,而不是预期的日期。为什么?
【问题讨论】:
-
我觉得应该是约会。
-
是的,但是为什么对象会出来?
-
如果你使用
"type": "object", "javaType": "java.util.Date而不是"type": "date"呢? -
它导致:线程“main”中的异常 java.lang.NoClassDefFoundError: japa/parser/ParseException at org.jsonschema2pojo.rules.ObjectRule.createClass(ObjectRule.java:235) at org.jsonschema2pojo .rules.ObjectRule.apply(ObjectRule.java:99) at org.jsonschema2pojo.rules.ObjectRule.apply(ObjectRule.java:66)
标签: java json pojo jsonschema