Skip to content

Serialize request body

This operation converts a request body object into an indented JSON string using a Newtonsoft-based serializer configured with the client's DateTimeZoneHandling and member-handling settings.

Field Value
Operation ID OP-04
Trigger RestSharp calls ISerializer.Serialize(object) when JsonHttpClient.GetJsonResponse invokes request.AddJsonBody(body).
Inputs Request body object.
Outputs Indented JSON string, with " as the quote character.
Primary components JsonSerializer.Serialize, JsonSerializer constructor
Entry point src/SAIF.Web.API.Clients/JsonSerializer.cs

Steps

  1. Open a StringWriter/JsonTextWriter pair for the output.
  2. Set Formatting.Indented and QuoteChar = '"' on the writer.
  3. Call _serializer.Serialize(...), applying MissingMemberHandling.Ignore, NullValueHandling.Include, DefaultValueHandling.Include, and the configured DateTimeZoneHandling (BR-07, BR-21).
  4. Return the resulting JSON string to RestSharp for inclusion in the request body.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["AddJsonBody invoked by<br>RestSharp"]) --> S1["Open StringWriter and<br>JsonTextWriter"]
    S1 --> S2["Configure<br>Formatting.Indented and<br>QuoteChar"]
    S2 --> S3["Serialize object with<br>configured settings"]
    S3 --> EndOk([Return JSON string])

Failure and edge-case behavior

  • No error handling is performed within this operation; serialization exceptions from Newtonsoft propagate to the caller unmodified.*

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • src/SAIF.Web.API.Clients/JsonSerializer.cs