如何移除API JSON响应中的方括号[]?(已解决:该问题此前迭代已修复,系误分配)
Hey folks, let's clear this up right away!
Background & Original Requirement
The original task was to adjust an API response that returned JSON in this format:
{"authorities": [{"authority": "Employee"}]}
The goal was to remove the square brackets ([]) from the response, converting the array structure into a single object output.
The related code setup includes:
- A Spring MVC endpoint mapped to
/authothat returns aResponseEntity<GetAuthorityResponse> - The
usr.getAuthorities()method (from Spring Security) returns aCollection<GrantedAuthority> GetAuthorityResponseconverts that collection to aCollection<CustomAuthority>, whereCustomAuthorityis an enum annotated with@JsonFormat(shape=JsonFormat.Shape.OBJECT)
Important Update
- This issue has already been fixed in a previous iteration
- This task was assigned by mistake, no further development or adjustments are needed here.
内容的提问来源于stack exchange,提问作者Adil
相关产品推荐
相关产品推荐

