diesieben07 diesieben07 - 1 year ago 66
Java Question

Default values with @ProjectedPayload / ProjectingJackson2HttpMessageConverter

I am using

on an interface to bind a JSON request body to a proxied instance of my interface.
My interface is as follows (in Kotlin, the
just translates to a Java getter):

interface ImportServer {

val id: UUID?
val name: String?


Now, the
here is completely optional, but there is no way for me to specify that, at least as far as I can tell. If I try to access the
property without it being present in the request body I will receive an exception from JsonPath:
com.jayway.jsonpath.PathNotFoundException: No results for path: $['id']
. If I could configure JsonPath I could use
and I'd get
for elements that are not present. But there is no way for me to get at the JsonPath configuration, it happens locked away inside

Is there a way for me to specify a default here? Or is there a way for me to detect if the
is present without accessing the
property in the first place?

Answer Source

That's a bug and has been fixed with DATACMNS-1145. Will be released with Ingalls SR7 and transitively with Boot 1.5.7.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download