GetLegendGraphic JSON returns layer title as a string instead of an object

In our GeoServer Cloud 3.0.2-based deployment, GetLegendGraphic with format=application/json returns a layer title containing JSON as a string. In our previous 2.26.2-based deployment, the same title was returned as an object.

For a layer whose catalog title is:

{“layerTitle”:“Example”,“legendTitle”:“”}

Request:

/geoserver/wms?service=WMS&request=GetLegendGraphic&format=application/json&layer=workspace:example

Expected Legend[0].title:

{“layerTitle”:“Example”,“legendTitle”:“”}

Actual Legend[0].title:

“{“layerTitle”:“Example”,“legendTitle”:”“}”

The behavior may be related to the json-lib migration in Sign in to GitHub · GitHub JSONLegendGraphicBuilder passes the title string to JSONObject.element. A standalone test with org.kordamp.json:json-lib-core:3.2.0-limit-fix reproduced the string serialization. We have not yet confirmed this with an unmodified upstream GeoServer build.