canton7 / canton7/RestEase

Content-Type Plain Text Deserialize Response

Open
#170 4 comments 0 reactions 0 assignees View on GitHub
restease-2.0
Dominant language
C#
Stars
1.1k
Forks
114
PR merge metrics
No merged PRs in 30d

Description

I'm trying to deserialise a Text/Plain response, however, found the JSON is the default. I've created the following but doesn't feel right, Isn't there an easier way? Moreover, it would be great in addition to JsonResponseDeserializer if there were more pre-made deserializer classes to pick from.

```

public override T Deserialize(string content, HttpResponseMessage response, ResponseDeserializerInfo info)
{
if(typeof(string).IsAssignableFrom(typeof(T)))
{
return (T)(object)content;
}

throw new InvalidDataException("Plain Text response deserializer can only be used with string");
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading JsonResponseDeserializer and the shown Deserialize override to understand the existing response-deserializer API. Check how response content types and string results are handled; done means a built-in plain-text option can deserialize text/plain responses without custom user code.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.