Open ben-manes opened 7 years ago
I think to support arbitrarily complex values for the default, we'd have to start using something like the Jackson ObjectMapper (or Gson, depending over what annotator is being used I guess). We could parse the value into a static field then reference this field as the default for instance fields.
I mean using the ObjectMapper in the generated source.
Yes, it might not be worthwhile especially if deserialization is required when creating a new instance. But perhaps then the observation here is that null
is specified as an element in the collection. If js2p cannot create the value, I don't think null is a friendly alternative.
@ben-manes Yes, I guess we should remove the null here and simply ignore defaults that we can't map (for the time being).
Is there any way to avoid initializing the collections with its default values? Right now I'm getting this invalid code that I would like to avoid
There is no way to ignore the defaults I'm afraid, although I'd welcome a patch.
This builds onto the discussion from #664. In this case I have a complex type to default, e.g.
Ideally the generated type would have,
but it generates,
Is it possible to generate complex types?