leadpony / justify

Justify is a JSON validator based on JSON Schema Specification and Jakarta JSON Processing API (JSON-P).
Apache License 2.0
96 stars 18 forks source link

JSONB Bind to Object + Default value support #62

Open mmadson opened 3 years ago

mmadson commented 3 years ago

Hi there!

Thanks for the great library. I'm digging into the examples but haven't been able to figure it out yet. Is there a way to perform the jsonb binding while also supporting default values; so that the serialized objects have the default values as specified in the spec?

Much appreciated.

leadpony commented 3 years ago

@mmadson

Sorry for late reply. I have added an experimental example which fills a Java object with default values specified in the JSON schema. https://github.com/leadpony/justify-examples/tree/binding-default/justify-examples-yasson

Unfortunately, we must use Yasson-specific API directly because pure JSON-B API does not accept JsonParser generated by an external library such as Justify.