restsharp / restsharp/RestSharp

String -> Json serialization

Open
#2,089 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
C#
Stars
9.8k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

I'm actually continuing discussion on this bug: https://github.com/restsharp/RestSharp/issues/1886

I have to send an arbitrary object via RestSharp. Currently the only possibility for me is to add the body via AddParameter(new JsonParameter("", json)) which seems quite ugly to me. It would be nice to add the bool forceSerialize parameter also to the generic AddJsonBody and not only to the string specialization. That way I could make sure that AddJsonBody serializes the object to a valid JSON for every type.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the generic AddJsonBody overload and the existing string specialization, then read the related discussion in issue 1886. Check how JsonParameter currently handles arbitrary objects. Done means the generic overload can accept forceSerialize and consistently serialize the supplied object to valid JSON; add or update focused tests for both overloads.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.