---
title: JsonSerializer
summary: API reference for JsonSerializer.
status: draft
owner: bendy
last_reviewed: 2026-09-15
library: SAIF.Web.API.Clients.35
reference_type: package
---

# JsonSerializer

`JsonSerializer` implements RestSharp's `ISerializer` interface using a Newtonsoft-based JSON writer, and is the type `JsonHttpClient` assigns to every `RestRequest.JsonSerializer` so that outbound request bodies serialize consistently with the client's configured `DateTimeZoneHandling` and member-handling settings ([BR-07](../../business-rules.md#br-07-configured-datetimezonehandling-applied-to-serialization), [BR-21](../../business-rules.md#br-21-serialization-member-and-value-handling)). The file carries an Apache 2.0 license header, having originally been contributed to RestSharp by John Sheehan / Daniel Crenna.

## Purpose
- Serialize an object to an indented JSON string using a Newtonsoft `Newtonsoft.Json.JsonSerializer` configured with `MissingMemberHandling.Ignore`, `NullValueHandling.Include`, `DefaultValueHandling.Include`, and the caller-selected `DateTimeZoneHandling`.
- Satisfy the `RestSharp.Serializers.ISerializer` contract so `JsonHttpClient` can plug it into a `RestRequest` for JSON body serialization.

## Context
- Namespace: `SAIF.Web.API.Clients`
- Assembly/package: `SAIF.Web.API.Clients` (net35 build variant; not shipped by the current package definition — see [Overview](../../overview.md))

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| ctor | `public JsonSerializer(DateTimeZoneHandling dateTimeZoneHandling = DateTimeZoneHandling.Local)` | Builds a Newtonsoft serializer configured with `MissingMemberHandling.Ignore`, `NullValueHandling.Include`, `DefaultValueHandling.Include`, and the supplied `DateTimeZoneHandling` ([BR-21](../../business-rules.md#br-21-serialization-member-and-value-handling)). |
| ctor | `public JsonSerializer(Newtonsoft.Json.JsonSerializer serializer)` | Accepts a fully custom, pre-configured Newtonsoft serializer instead of building one from defaults. |
| `Serialize` | `public string Serialize(object obj)` | Serializes the given object to an indented JSON string using `"` as the quote character; the entry point RestSharp calls for `AddJsonBody` (see [Serialize request body](../../operations/op-04-serialize-request-body.md)). |
| `DateFormat` | `public string DateFormat { get; set; }` | Required to satisfy `ISerializer`; unused for JSON serialization. |
| `RootElement` | `public string RootElement { get; set; }` | Required to satisfy `ISerializer`; unused for JSON serialization. |
| `Namespace` | `public string Namespace { get; set; }` | Required to satisfy `ISerializer`; unused for JSON serialization. |
| `ContentType` | `public string ContentType { get; set; }` (default `application/json`) | Content type reported to RestSharp for the serialized body. |

## Behavioral notes
- `DateFormat`, `RootElement`, and `Namespace` exist only to satisfy the `RestSharp.Serializers.ISerializer` interface contract; none of them affect JSON output.*

## Constraints and usage notes
- The linked source imports `RestSharp.Serialization.Json`, a namespace introduced in the RestSharp 106.x line, while this `.35` project pins RestSharp 105.2.3 — the namespace is not expected to exist in the pinned assembly, a build-viability concern documented in [Architecture](../../architecture.md).*

> **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
