Quarkus is unable to serialize a simple string as JSON

61 views Asked by At

My Quarkus app has a single class, which is the following:

package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String hello(){
        return "Hello from Quarkus REST";
    }
}

The expected response would be:

200 OK HTTP/1.1
Content-Type: application/json

"Hello from Quarkus REST"

Instead, it returns:

200 OK HTTP/1.1
Content-Type: application/json

Hello from Quarkus REST

The JSON cannot be parsed since it is not valid because of the missing quotes.

Any idea why Jackson is not serializing my String as JSON ?

It seems weird because the Content-Type header is still indicating that the response is a JSON.

I can't find anything documenting this behavior on Quarkus website.

0

There are 0 answers