I construct a new JObject
instance the following way:
return new JObject(
new JProperty("prop1", prop1),
new JProperty("prop2", prop2))
I would like, however, to add a key/value pair only if the value is not null. E.g. if prop1
is null, I'd like no a key/value pair 'prop1': null
to be added. Can this be done in an elegant way?