# Response Serialization — Fastify: High-Performance Node.js APIs बनाना

Source: https://www.skillbyai.com/hi/fastify/ff-serialization

> Response schemas घोषित करके JSON responses तेज़ करें, जिन्हें Fastify केवल सूचीबद्ध fields के लिए serialize करता है।

## Schema-based serialization

Schema में `response` field Fastify को बताता है कि कौन-से fields भेजने हैं, केवल declared properties को शामिल करके JSON serialization को तेज़ करता है।

## Response schema

Define करें कि response कैसा दिखता है। Fastify केवल schema में fields को serialize करेगा।

```javascript
const getUserSchema = {
  response: {
    200: {
      type: 'object',
      properties: {
        id: { type: 'integer' },
        name: { type: 'string' },
        email: { type: 'string' },
      },
    },
  },
};

fastify.get('/users/:id', { schema: getUserSchema }, async (req) => {
  return {
    id: 1,
    name: 'Alice',
    email: 'alice@example.com',
    // password field will be stripped by serialization
  };
});
```
