You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently mapping various schema types to primitive types, which doesn't work well when incoming JSON omits a property altogether. Since Java properties with primitive types are obviously not nullable, we end up with implicit defaults, and no way to distinguish between a value that was omitted and a value that was equal to the primitive default value.
Simple example...
for this schema:
{
"type" : "object",
"properties" : {
"a" : {
"type" : "integer"
}
}
}
we end up with a Java property of type 'int', and hence this data:
{ "a" : 0 }
is indistinguishable from this data:
{}
Clearly this is a significant change to the way POJO generation works (a breaking change in some rare cases where auto-boxing is not enough to keep things happy), hence this is targetted for 0.2.0.
Although the default is now to use wrapper types (and support nullable properties), there's now a new behavioural property 'usePrimitives' (--use-primitives or -P for the CLI) to switch to old behaviour and use primitive types.
As part of this change, we've moved away from the behavioural properties 'map of strings' and now have a strongly typed config interface:
com.googlecode.jsonschema2pojo.GenerationConfig
Both the maven plugin and CLI argument object implement this interface, which reduces duplication and adds compile time checking when adding new properties.
For the CLI, we've switched from commons-cli to JCommander. CLI arguments are now expressed via annotations on a config object, which makes implementing the GenerationConfig interface easy in the CLI module.
Original author: joelittl...@gmail.com (July 06, 2011 23:08:55)
We're currently mapping various schema types to primitive types, which doesn't work well when incoming JSON omits a property altogether. Since Java properties with primitive types are obviously not nullable, we end up with implicit defaults, and no way to distinguish between a value that was omitted and a value that was equal to the primitive default value.
Simple example...
for this schema:
{
"type" : "object",
"properties" : {
"a" : {
"type" : "integer"
}
}
}
we end up with a Java property of type 'int', and hence this data:
{ "a" : 0 }
is indistinguishable from this data:
{}
Clearly this is a significant change to the way POJO generation works (a breaking change in some rare cases where auto-boxing is not enough to keep things happy), hence this is targetted for 0.2.0.
Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=31
The text was updated successfully, but these errors were encountered: