# Newtonsoft.Json

**Kind:** Service

**Source:** `Pams/Logic/Pams.Email/Pams.Email.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Newtonsoft.Json` is a NuGet package dependency referenced by the `Pams.Email` project. The email service uses it to serialize application models into JSON and deserialize JSON payloads received from integrations or stored data.

## Diagram

```mermaid
sequenceDiagram
    participant Caller
    participant EmailService as Pams.Email
    participant Json as Newtonsoft.Json

    Caller->>EmailService: Send email payload
    EmailService->>Json: Serialize email model
    Json-->>EmailService: JSON text
    EmailService-->>Caller: Return JSON response
```

## Usage

```ts
type EmailPayload = {
  to: string;
  subject: string;
  body: string;
};

const payload: EmailPayload = {
  to: "recipient@example.com",
  subject: "Status update",
  body: "Your request has been processed."
};

// The Pams.Email service serializes the received payload with Newtonsoft.Json.
const response = await fetch("/api/email", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

const result = await response.json();
console.log(result);
```

## AI Coding Instructions

- Keep JSON property names and payload shapes compatible with existing `Pams.Email` callers and integrations.
- Use `Newtonsoft.Json` from the project dependency rather than adding another JSON library for the same serialization path.
- Do not import the NuGet package directly from TypeScript or JavaScript; browser and client code should exchange JSON through HTTP APIs.
- Review serialization settings when changing email models, especially null handling, date formatting, and property naming.
