Skip to content

NestedJsonProvider: unable to omit empty nested field #764

Open
@brenuart

Description

@brenuart

Most JsonProviders omit writing their field(s) if their value is null (absent). This is however not the case for the NestedJsonProvider. Consider the following configuration:

<providers>
   <nestedField>
      <fieldName>nested</fieldName>
      <providers>
         <mdc/>
      </providers>
   </nestedField>
</providers>

This configuration produces a JSON similar to the following:

{
   "nested": {
      "mdc1": "value1",
      "mdc2": "value2"
   }
}

However when not MDC keys are present or if none matches the include pattern of the MDC json provider, the "nested" object becomes empty and the output looks as follows:

{
   "nested": {
   }
}

There is unfortunately no option to omit the nested object when it is empty similar to what is available to the PatternJsonProvider.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions