Malformed JSON with Interfaces in the Response DTO

Hi Demis,

when we use an interface in a response DTO the JSON is malformed:

__type is missing the double quotes.

Shouldn’t __type: be "__type:" ?

Thks

In the screenshot you’ve shown, it appears that none of the JSON properties have quotes around them when in actual fact they do.

Are you sure this isn’t just how it appears in the viewer you are using? I just created a new project and tried the following with IncludeTypeInfo = true.

Service:

public class MyServices : Service
{
    public object Any(Hello request)
    {
        var response = new HelloResponse { Result = "Hello, {0}!".Fmt(request.Name) };
        return (IFoo)response;
    }
}

[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
    public string Name { get; set; }
}

public class HelloResponse : IFoo
{
    public string Result { get; set; }

    public int Test { get; set; }
}

public interface IFoo
{
    int Test { get; set; }
    string Result { get; set; }
}

JSON response is:

{"__type":"WebApplication2.ServiceModel.HelloResponse, WebApplication2.ServiceModel","Result":"Hello, foo1!","Test":0}

Can you show the actual JSON response to confirm it is actually malformed?

@layoric actually I noticed this with Postman (the malformed JSON).

I’m currently using 4.0.34 but I will try this again tomorrow with 4.0.34 and the latest myGET release.

Thks

@carlosmendes It looks like this is a screenshot using Chrome’s prettyfied JSON viewer, please note this doesn’t show the raw JSON, e.g. it displays collapsable Objects and strips quotes from JSON keys. If you view it without the JSON Viewer you’ll see that each key is infact quoted.