【发布时间】:2015-05-21 11:32:41
【问题描述】:
我正在使用 FasterXML 的 json-schema generator 从我的 POJO 构建 json-schema。 一切正常,直到我的 POJO 使用自定义 json 序列化。就我而言,我有一个 org.joda.Money 类型的字段,并使用相应的 joda-module 对其进行序列化。 bean 被很好地序列化了
{
"amount": "...",
"currency": "..."
}
但它的架构是这样的:
{
"type" : "object",
"id" : "urn:jsonschema:org:joda:money:Money",
"properties" : {
"amount" : {
"type" : "number"
},
"amountMinorLong" : {
"type" : "integer"
},
"scale" : {
"type" : "integer"
},
"minorPart" : {
"type" : "integer"
},
"positive" : {
"type" : "boolean"
},
"amountMajor" : {
"type" : "number"
},
"amountMinor" : {
"type" : "number"
},
"amountMinorInt" : {
"type" : "integer"
},
"positiveOrZero" : {
"type" : "boolean"
},
"zero" : {
"type" : "boolean"
},
"negative" : {
"type" : "boolean"
},
"amountMajorLong" : {
"type" : "integer"
},
"amountMajorInt" : {
"type" : "integer"
},
"negativeOrZero" : {
"type" : "boolean"
},
"currencyUnit" : {
"type" : "object",
"id" : "urn:jsonschema:org:joda:money:CurrencyUnit",
"properties" : {
"symbol" : {
"type" : "string"
},
"numeric3Code" : {
"type" : "string"
},
"countryCodes" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"code" : {
"type" : "string"
},
"decimalPlaces" : {
"type" : "integer"
},
"defaultFractionDigits" : {
"type" : "integer"
},
"currencyCode" : {
"type" : "string"
},
"pseudoCurrency" : {
"type" : "boolean"
},
"numericCode" : {
"type" : "integer"
}
}
}
}
}
有没有办法自定义生成的架构?
【问题讨论】:
-
我想知道您使用哪个模块对 Joda Money 进行序列化和反序列化?
-
这里是:
<dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-joda</artifactId> <version>2.4.4</version> </dependency> -
我认为它不包含 Joda Money 模块。看我的回答。
标签: json jackson jsonschema fasterxml jackson-modules