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, BR-21). 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.JsonSerializerconfigured withMissingMemberHandling.Ignore,NullValueHandling.Include,DefaultValueHandling.Include, and the caller-selectedDateTimeZoneHandling. - Satisfy the
RestSharp.Serializers.ISerializercontract soJsonHttpClientcan plug it into aRestRequestfor 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)
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). |
| 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). |
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, andNamespaceexist only to satisfy theRestSharp.Serializers.ISerializerinterface 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.35project pins RestSharp 105.2.3 — the namespace is not expected to exist in the pinned assembly, a build-viability concern documented in Architecture.*
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