App-Schema GeoJSON output ignores property/element nesting

Description

Property/element nesting is currently ignored by the complex GeoJSON encoder, for reference:
https://github.com/geoserver/geoserver/blob/master/src/wfs/src/main/java/org/geoserver/wfs/json/ComplexGeoJsonWriter.java#L388-L430

Would be great to include the nesting of schema elements where the maxOccurs="unbounded" or > 1 also in the GeoJSON outputs for complex services.

Currently where multiple properties of the same type have been encoded using the app-schema mapping syntax below, only the last property is included in the GeoJSON output.

https://docs.geoserver.org/latest/en/user/data/app-schema/feature-chaining.html#configure-nesting-on-the-nested-feature-type

GeologicUnit has 3 gml:name properties in the mapping file, so each has a code space to clarify them:
<AttributeMapping>
<targetAttribute>gml:name[1]</targetAttribute>
<sourceExpression>
<OCQL>ABBREVIATION</OCQL>
</sourceExpression>
<ClientProperty>
<name>codeSpace</name>
<value>'urn:cgi:classifierScheme:GSV:GeologicalUnitCode'</value>
</ClientProperty>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>gml:name[2]</targetAttribute>
<sourceExpression>
<OCQL>NAME</OCQL>
</sourceExpression>
<ClientProperty>
<name>codeSpace</name>
<value>'urn:cgi:classifierScheme:GSV:GeologicalUnitName'</value>
</ClientProperty>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>gml:name[3]</targetAttribute>
<sourceExpression>
<OCQL>id</OCQL>
</sourceExpression>
<ClientProperty>
<name>codeSpace</name>
<value>'urn:cgi:classifierScheme:GSV:MappedFeatureReference'</value>
</ClientProperty>
</AttributeMapping>

https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/4c74bb9d94e3400eaae9c0cd06beb5ac%40au01stnd03e01.SAGS.CSFM.GLOBAL/#msg36895000

https://sourceforge.net/p/geoserver/mailman/geoserver-users/thread/19d0b9dbf8634344ad7199338b0d1a6e%40ADL1STND03E01.SAGS.CSFM.GLOBAL/#msg36895828

Environment

None

Assignee

Unassigned

Reporter

Ursula Michael

Triage

None

Fix versions

None

Affects versions

Components

Priority

Medium
Configure