Why does Quarkus @Produces(MediaType.APPLICATION_JSON) automatically add the array wrapper and comma to values? #28925
Unanswered
Aravinda93
asked this question in
Q&A
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a POST Rest API developed using Quarkus with
@Produces(MediaType.APPLICATION_JSON)
this method returns the list of customers asynchronously. But the problem is that it adds the additional array wrapper and comma separation, which is not required. Everything works fine when used withMediaType.TEXT_PLAIN
but since my response is of JSON type I want to keepMediaType.APPLICATION_JSON
. Is there anyway to avoid the modification to response?For example following is the response I am getting with
@Produces(MediaType.APPLICATION_JSON)
. You can see it adds unwanted commas and arrays within my response:The response I would like is correctly achievable with
MediaType.TEXT_PLAIN
:When I use text/plain, everything works fine. Is there something that I can modify to avoid the addition of array wrapper and comma when using with
application/json
?I believe this is happening because I am generating the elements in
customerList
asynchronously using theSmallRye Mutin Multi<String>
. Can someone please provide some suggestion?The following is the Quarkus Rest API for GET requests:
Beta Was this translation helpful? Give feedback.
All reactions